summaryrefslogtreecommitdiff
path: root/userspace/piper.c
diff options
context:
space:
mode:
Diffstat (limited to 'userspace/piper.c')
-rw-r--r--userspace/piper.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/userspace/piper.c b/userspace/piper.c
index 2272f96..73b9516 100644
--- a/userspace/piper.c
+++ b/userspace/piper.c
@@ -1,21 +1,42 @@
#include <stdio.h>
int main()
{
- int pid=_fork();
+ setvbuf(stdout,NULL,_IONBF,0);
+ /*
FILE *f=fopen("~testpipe","rw");
- setvbuf(f,NULL,_IONBF,0);
+ int pid=_fork();
if(pid==0)
{
char buf[2];
- fread(f,buf,1,1);
+ fread(buf,1,1,f);
printf("[%c]\n",buf[0]);
+ while(1);
+ }
+
+ else
+ {
+ char buf[]="666";
+ fwrite(buf,1,1,f);
+ printf("written\n");
+ while(1);
}
+ */
+ int f=_open("~testpipe","RW");
+ int pid=_fork();
+ if(pid==0)
+ {
+ char buf[2];
+ while(_read(f,buf,1))printf("%c",buf[0]);
+ }
+
else
{
- char buf="666";
- fwrite(f,buf,1,1);
+ char buf[]="666 the number of the beast";
+ _write(f,buf,27);
printf("written\n");
}
+
+
}