chiark
/
gitweb
/
~mdw
/
distorted-chroot
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/jobclient.c: Cope if the jobserver pipe is set nonblocking.
[distorted-chroot]
/
src
/
jobclient.c
diff --git
a/src/jobclient.c
b/src/jobclient.c
index bc8d85890da59a767a9f0ed81a5afaa49820c6da..02141d4718098b0a916851c27a002ca54197ae31 100644
(file)
--- a/
src/jobclient.c
+++ b/
src/jobclient.c
@@
-33,6
+33,7
@@
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/select.h>
#include <unistd.h>
#define PY_SSIZE_T_CLEAN
#include <unistd.h>
#define PY_SSIZE_T_CLEAN
@@
-52,6
+53,7
@@
static PyObject *pymeth_jobclient(PyObject *me, PyObject *arg)
PyObject *rc = 0;
struct sigaction sa, oldsa;
sigset_t mask, oldmask;
PyObject *rc = 0;
struct sigaction sa, oldsa;
sigset_t mask, oldmask;
+ fd_set infd;
int rstrchld = 0;
int fd, sfd;
int kid, st;
int rstrchld = 0;
int fd, sfd;
int kid, st;
@@
-101,7
+103,11
@@
again:
* like this happens, then we go back and try reaping children again.
*/
Py_BEGIN_ALLOW_THREADS
* like this happens, then we go back and try reaping children again.
*/
Py_BEGIN_ALLOW_THREADS
- n = read(sigfd, &ch, 1);
+ for (;;) {
+ n = read(sigfd, &ch, 1); if (n >= 0 || errno != EAGAIN) break;
+ FD_ZERO(&infd); FD_SET(sigfd, &infd);
+ n = select(sigfd + 1, &infd, 0, 0, 0); if (n < 0) break;
+ }
Py_END_ALLOW_THREADS
if (n == 1) rc = Py_BuildValue("(cOO)", ch, Py_None, Py_None);
else if (!n) rc = Py_BuildValue("(sOO)", "", Py_None, Py_None);
Py_END_ALLOW_THREADS
if (n == 1) rc = Py_BuildValue("(cOO)", ch, Py_None, Py_None);
else if (!n) rc = Py_BuildValue("(sOO)", "", Py_None, Py_None);