[FS] Pipes

This commit is contained in:
thomas committed 2017-03-27 23:09:10 +02:00
1 parent fd782365b7
commit 4bb9021885
8 files changed
+238 -2

No files matched your search

+21 -2
View File
@@ -8,8 +8,27 @@ int main(int argc, char **argv)
(void) argv;
FILE *fp = fopen("/dev/debug", "w");
fprintf(fp, "Hello, filesystem!\n");
int fd[2];
pipe(fd);
pid_t childpid = fork();
if(childpid)
{
printf("I am parent!\n");
close(fd[1]);
write(fd[0], "Hi, pipe!\n", 10);
close(fd[0]);
}
else
{
printf("I am child!\n");
close(fd[0]);
char buffer[255];
read(fd[1], buffer, 255);
printf("Received string: %s\n", buffer);
close(fd[1]);
}
for(;;);