summaryrefslogtreecommitdiff
path: root/userspace/piper.c
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-15 12:25:13 +0200
committerMiguel <m.i@gmx.at>2018-09-15 12:25:13 +0200
commit0b010d22dbf845ad030e2e7320f9c5935b2604a4 (patch)
tree6683b09a89b9e19630ef197343a8ace53a765c82 /userspace/piper.c
parentfe7d0332267ef1e62153b685d2b5574ce624a4bc (diff)
brainfuck interpreter works!
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");
}
+
+
}