2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
7 #include <proto/exec.h>
16 /*****************************************************************************
42 ******************************************************************************/
45 fcb
*rfcb
= NULL
, *wfcb
= NULL
;
46 fdesc
*rdesc
= NULL
, *wdesc
= NULL
;
47 /* PIPE:cpipe-%08x-%d, where %x is the getpid(), %d is the nth pipe */
48 char pipe_name
[5 + 6 + 8 + 1 + 16 + 1];
49 static int pipeno
= 0;
59 (rfcb
= AllocVec(sizeof(fcb
), MEMF_ANY
| MEMF_CLEAR
)) == NULL
||
60 (rdesc
= __alloc_fdesc()) == NULL
||
61 (wfcb
= AllocVec(sizeof(fcb
), MEMF_ANY
| MEMF_CLEAR
)) == NULL
||
62 (wdesc
= __alloc_fdesc()) == NULL
75 /* Get the next pipe number */
80 snprintf(pipe_name
, sizeof(pipe_name
), "PIPE:cpipe-%08lx-%d",
81 (unsigned long)getpid(), pipeno
);
82 pipe_name
[sizeof(pipe_name
)-1] = 0;
84 writer
= Open(pipe_name
, MODE_NEWFILE
);
87 reader
= Open(pipe_name
, MODE_OLDFILE
);
90 DeleteFile(pipe_name
);
98 errno
= __stdc_ioerr2errno(IoErr());
104 pipedes
[0] = __getfdslot(__getfirstfd(0));
107 rdesc
->fcb
->handle
= reader
;
108 rdesc
->fcb
->flags
= O_RDONLY
;
109 rdesc
->fcb
->opencount
= 1;
110 __setfdesc(pipedes
[0], rdesc
);
112 pipedes
[1] = __getfdslot(__getfirstfd(pipedes
[0]));
115 wdesc
->fcb
->handle
= writer
;
116 wdesc
->fcb
->flags
= O_WRONLY
;
117 wdesc
->fcb
->opencount
= 1;
118 __setfdesc(pipedes
[1], wdesc
);