2 ** Copyright 2003, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
8 #include <sys/syscalls.h>
10 static int pipe_read_thread(void *args
)
12 int fd
= *(int *)args
;
18 err
= read(fd
, buf
, sizeof(buf
));
19 printf("pipe_read_thread: read returns %d\n", err
);
32 static int pipe_test(void)
40 printf("pipe returns %d\n", err
);
41 printf("%d %d\n", fds
[0], fds
[1]);
44 id
= sys_thread_create_thread("pipe read thread", &pipe_read_thread
, &fds
[1]);
45 sys_thread_resume_thread(id
);
49 err
= write(fds
[0], "this is a test", sizeof("this is a test"));
50 printf("write returns %d\n", err
);
60 // close the reader end and write to it
62 err
= write(fds
[0], "this is a test", sizeof("this is a test"));
63 printf("write returns %d\n", err
);