fork #include "unistd.h" #include "fcntl.h" #include "stdio.h" int main() { int fd = open("/tmp/tmp.txt", O_CREAT|O_TRUNC|O_WRONLY, 0777); if (fork() == 0) { printf("[child] fd = %d\n", fd); write(fd, "child\n", 6); } else { printf("[parent] fd = %d\n", fd); write(fd, "parent\n", 7); } } --- fork bummer int main() { printf("hello world "); fork(); printf("hello again\n"); } --- pipe int main() { int fdarray[2]; char buf[512]; int n, pid; pipe(fdarray); pid = fork(); if(pid > 0){ write(fdarray[1], "hello", 5); } else { n = read(fdarray[0], buf, sizeof(buf)); printf("%s\n", buf); } }