diff options
author | rtm <rtm> | 2006-06-27 14:35:53 +0000 |
---|---|---|
committer | rtm <rtm> | 2006-06-27 14:35:53 +0000 |
commit | c41f1de5d41a527a3fa2d1e94215766130eac456 (patch) | |
tree | 86f6a467be8b42aec42a05299789f39ace9cc5e2 /user1.c | |
parent | b61c2547b8b489cab16984c0940a1cb6593a2a3d (diff) | |
download | xv6-labs-c41f1de5d41a527a3fa2d1e94215766130eac456.tar.gz xv6-labs-c41f1de5d41a527a3fa2d1e94215766130eac456.tar.bz2 xv6-labs-c41f1de5d41a527a3fa2d1e94215766130eac456.zip |
file descriptors
pipes
Diffstat (limited to 'user1.c')
-rw-r--r-- | user1.c | 38 |
1 files changed, 11 insertions, 27 deletions
@@ -1,35 +1,19 @@ -int -fork() -{ - asm("mov $1, %eax"); - asm("int $48"); -} - -void -cons_putc(int c) -{ - asm("mov $4, %eax"); - asm("int $48"); -} - -int -puts(char *s) -{ - int i; - - for(i = 0; s[i]; i++) - cons_putc(s[i]); - return i; -} +char buf[32]; main() { - int pid; + int pid, fds[2], n; + + pipe(fds); pid = fork(); - if(pid == 0){ - cons_putc('C'); + if(pid > 0){ + write(fds[1], "xyz", 4); + puts("w"); } else { - cons_putc('P'); + n = read(fds[0], buf, sizeof(buf)); + puts("r: "); + puts(buf); + puts("\n"); } while(1) ; |