summaryrefslogtreecommitdiff
path: root/userspace/piper.c
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-20 20:51:57 +0200
committerMiguel <m.i@gmx.at>2018-09-20 20:51:57 +0200
commitaeefdb37d1fc1c0eb7953b9c196cab09460bc167 (patch)
tree513789d7fd28b65afb594e9605975bd10ea06f74 /userspace/piper.c
parent763f85c55fdb5a2c4f5bf98e4989a69d27da6e4f (diff)
we are now prepared for piping with _pipe and _dup2
Diffstat (limited to 'userspace/piper.c')
-rw-r--r--userspace/piper.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/userspace/piper.c b/userspace/piper.c
index e433a5c..f45248e 100644
--- a/userspace/piper.c
+++ b/userspace/piper.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include "newcalls.h"
+
int main()
{
int fds[2];
@@ -15,7 +16,11 @@ int main()
{
char buf[256];
int len=fread(buf,1,255,fds[0]);
- printf("%s",buf);
+ //int len=_read(fds[0],buf,255);
+ buf[len]=0;
+ printf("-\n");
+ printf("%s\n",buf);
+ printf("-\n");
}
}
@@ -23,9 +28,8 @@ int main()
{
// write to our pipe
- fwrite("Hello\n",1,6,fds[1]);
- fwrite("Bello\n",1,6,fds[1]);
- fwrite("Gello\n",1,6,fds[1]);
+ _write(fds[1],"Hello\n",fds[1]);
+ _write(fds[1],"Bello\n",fds[1]);
// hang forever
while(1);