swee

swee / silly syscall chaos

Last active 5 days ago

Like 0
main.c Raw
1#include <unistd.h>
2#include <fcntl.h>
3
4int main(void) {
5 int fd = open("meow.txt", O_WRONLY|O_CREAT, 0640);
6 if (fd != -1) {
7 write(fd, "meow :3\n", 8);
8 write(1, "written\n", 8);
9 close(fd);
10 }
11 fd = open("meow.txt", O_RDONLY);
12 if (fd != -1) {
13 char meow[8];
14 read(fd, meow, 8);
15 write(1, "read\n", 5);
16 write(1, meow, 8);
17 close(fd);
18 }
19 return 0;
20}