better error handling
This commit is contained in:
parent
70e112b892
commit
b27aa1a9d8
14
io/io_pipe.c
14
io/io_pipe.c
@ -11,14 +11,12 @@ int io_pipe(int64* d) {
|
|||||||
if (pipe(fds)==-1)
|
if (pipe(fds)==-1)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
if (io_fd(fds[1])) {
|
if (io_fd(fds[1]) && io_fd(fds[0])) {
|
||||||
if (io_fd(fds[0])) {
|
d[0]=fds[0];
|
||||||
d[0]=fds[0];
|
d[1]=fds[1];
|
||||||
d[1]=fds[1];
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
io_close(fds[1]);
|
|
||||||
}
|
}
|
||||||
close(fds[0]);
|
io_close(fds[1]);
|
||||||
|
io_close(fds[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,12 @@ int io_socketpair(int64* d) {
|
|||||||
if (socketpair(AF_INET6,SOCK_STREAM,IPPROTO_TCP,fds)==-1)
|
if (socketpair(AF_INET6,SOCK_STREAM,IPPROTO_TCP,fds)==-1)
|
||||||
if (socketpair(AF_INET,SOCK_STREAM,IPPROTO_TCP,fds)==-1)
|
if (socketpair(AF_INET,SOCK_STREAM,IPPROTO_TCP,fds)==-1)
|
||||||
return 0;
|
return 0;
|
||||||
if (io_fd(fds[1])) {
|
if (io_fd(fds[1]) && io_fd(fds[0])) {
|
||||||
if (io_fd(fds[0])) {
|
d[0]=fds[0];
|
||||||
d[0]=fds[0];
|
d[1]=fds[1];
|
||||||
d[1]=fds[1];
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
io_close(fds[1]);
|
|
||||||
}
|
}
|
||||||
close(fds[0]);
|
io_close(fds[1]);
|
||||||
|
io_close(fds[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user