Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2004-03-13 01:03:33 +0300
committerChristopher Faylor <me@cgf.cx>2004-03-13 01:03:33 +0300
commit183f4d8086961fc8cedb951e3cdc98475d73bd71 (patch)
treea764217b2762cdb87f54b8ecbf2a27835374a7e0 /winsup/cygwin/wait.cc
parent07411d4c2e9bed0a056477ab3050d38842546598 (diff)
* wait.cc (wait4): Initialize pointer on entry. Avoid calling
call_signal_handler twice since that guarantees exiting with errno set to EINTR.
Diffstat (limited to 'winsup/cygwin/wait.cc')
-rw-r--r--winsup/cygwin/wait.cc21
1 files changed, 8 insertions, 13 deletions
diff --git a/winsup/cygwin/wait.cc b/winsup/cygwin/wait.cc
index fda951ead..4fa53bac6 100644
--- a/winsup/cygwin/wait.cc
+++ b/winsup/cygwin/wait.cc
@@ -48,25 +48,23 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
{
int res;
HANDLE waitfor;
- waitq *w;
+ waitq *w = &_my_tls.wq;
pthread_testcancel ();
while (1)
{
sig_dispatch_pending ();
- bool sawsig = false;
if (options & ~(WNOHANG | WUNTRACED))
{
set_errno (EINVAL);
- return -1;
+ res = -1;
+ break;
}
if (r)
memset (r, 0, sizeof (*r));
- w = &_my_tls.wq;
-
w->pid = intpid;
w->options = options;
w->rusage = r;
@@ -77,7 +75,7 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
set_errno (ENOSYS);
paranoid_printf ("proc_subproc returned 0");
res = -1;
- goto done;
+ break;
}
if ((waitfor = w->ev) == NULL)
@@ -93,14 +91,14 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
/* found no children */
set_errno (ECHILD);
res = -1;
- goto done;
+ break;
}
if (w->status == -1)
{
+ if (_my_tls.call_signal_handler ())
+ continue;
set_sig_errno (EINTR);
- _my_tls.call_signal_handler ();
- sawsig = true;
res = -1;
}
else if (res != WAIT_OBJECT_0)
@@ -112,10 +110,7 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
}
else if ((res = w->pid) != 0 && status)
*status = w->status;
-
- done:
- if (!sawsig || !_my_tls.call_signal_handler ())
- break;
+ break;
}
sigproc_printf ("intpid %d, status %p, w->status %d, options %d, res %d",