[FS] Pipes

This commit is contained in:
2017-03-20 15:07:07 +01:00
parent fd782365b7
commit 4bb9021885
8 changed files with 238 additions and 2 deletions

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(;;);