Don't call ReadArgs() if started from WB.
[tangerine.git] / compiler / clib / pipe.c
blobb3ceca5a77098c3b8a9ef8938f34ea1269597d40
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/dos.h>
8 #include <unistd.h>
9 #include <fcntl.h>
10 #include <errno.h>
12 #include "__open.h"
14 static int clear_nonblock_flag (int desc)
16 int oldflags = fcntl(desc, F_GETFL, 0);
18 if (oldflags == -1)
19 return -1;
21 oldflags &= ~O_NONBLOCK;
23 return fcntl(desc, F_SETFL, oldflags);
26 int pipe(int *pipedes)
28 if (!pipedes)
30 errno = EFAULT;
32 return -1;
35 pipedes[0] = open("PIPEFS:__UNNAMED__", O_RDONLY|O_NONBLOCK);
36 if (pipedes[0] != -1)
38 fdesc *desc = __getfdesc(pipedes[0]);
39 BPTR olddir = CurrentDir(desc->fh);
43 clear_nonblock_flag(pipedes[0]) != -1 &&
44 ((pipedes[1] = open("", O_WRONLY)) != -1)
47 CurrentDir(olddir);
49 return 0;
52 CurrentDir(olddir);
53 close(pipedes[0]);
56 return -1;