2003-09-02 00:14:04 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include "io_internal.h"
|
|
|
|
|
|
|
|
int io_pipe(int64* d) {
|
2003-11-06 20:47:59 +00:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
HANDLE fds[2];
|
|
|
|
if (CreatePipe(fds,fds+1,0,0)==0)
|
|
|
|
return 0;
|
|
|
|
#else
|
2003-09-02 00:14:04 +00:00
|
|
|
int fds[2];
|
|
|
|
if (pipe(fds)==-1)
|
|
|
|
return 0;
|
2003-11-06 20:47:59 +00:00
|
|
|
#endif
|
2021-03-12 16:23:32 +00:00
|
|
|
if (io_fd_canwrite(fds[1]) && io_fd(fds[0])) {
|
2004-02-27 14:50:28 +00:00
|
|
|
d[0]=fds[0];
|
|
|
|
d[1]=fds[1];
|
|
|
|
return 1;
|
2003-09-02 00:14:04 +00:00
|
|
|
}
|
2004-02-27 14:50:28 +00:00
|
|
|
io_close(fds[1]);
|
|
|
|
io_close(fds[0]);
|
2003-09-02 00:14:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|