commit - 2f1f196eeb0a20952b4d4a5914c9d54f50e32d97
commit + dc3e25b130aee2682cc370e9505fd7386cbe8b53
blob - fb082239dfb4bc5d58976a3c4c925d3ef9048873
blob + 34f6474a60c36c69c8755554776633328c8cb829
--- ev.c
+++ ev.c
int
ev_signal(int sig, void (*cb)(int, int, void *), void *udata)
{
+ int flags;
+
if (base->sigpipe[0] == -1) {
- if (pipe2(base->sigpipe, O_NONBLOCK) == -1)
+ /* pipe2(2) is not available everywhere... sigh */
+ if (pipe(base->sigpipe) == -1)
+ return -1;
+
+ if ((flags = fcntl(base->sigpipe[1], F_GETFL)) == -1 ||
+ fcntl(base->sigpipe[1], F_SETFL, flags | O_NONBLOCK) == -1)
return -1;
+
if (ev_add(base->sigpipe[0], POLLIN, ev_sigdispatch, NULL)
== -1)
return -1;