diff --git a/src/kernel/libroot/posix/unistd/Jamfile b/src/kernel/libroot/posix/unistd/Jamfile index a9f0001493..a33d05df74 100644 --- a/src/kernel/libroot/posix/unistd/Jamfile +++ b/src/kernel/libroot/posix/unistd/Jamfile @@ -15,6 +15,7 @@ KernelMergeObject posix_unistd.o : <$(SOURCE_GRIST)>lseek.c <$(SOURCE_GRIST)>mount.c <$(SOURCE_GRIST)>open.c + <$(SOURCE_GRIST)>pipe.c <$(SOURCE_GRIST)>read.c <$(SOURCE_GRIST)>sleep.c <$(SOURCE_GRIST)>terminal.c diff --git a/src/kernel/libroot/posix/unistd/pipe.c b/src/kernel/libroot/posix/unistd/pipe.c new file mode 100644 index 0000000000..51516f47ca --- /dev/null +++ b/src/kernel/libroot/posix/unistd/pipe.c @@ -0,0 +1,34 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + + +#include + +#include +#include +#include + + +int +pipe(int streams[2]) +{ + // ToDo: if the thread manages to call this function during the + // the same microsecond twice, we're doomed :) + char pipeName[64]; + sprintf(pipeName, "/pipe/%lx-%Ld\n", find_thread(NULL), system_time()); + + streams[0] = open(pipeName, O_CREAT | O_RDONLY, 0777); + if (streams[0] < 0) + return -1; + + streams[1] = open(pipeName, O_WRONLY); + if (streams[1] < 0) { + close(streams[0]); + return -1; + } + + return 0; +} +