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>2001-01-16 05:29:47 +0300
committerChristopher Faylor <me@cgf.cx>2001-01-16 05:29:47 +0300
commit9470a80c8b707aa0c58ae0029ce2a7b4669d1c74 (patch)
tree43115d833804daf7e5680cc3369b7b875a310eb2 /winsup/cygwin/wait.cc
parent9334c89c1da674a01df89be9e8e0afeb8f062c57 (diff)
* wait.cc (wait4): Rename variable for consistency. Allow restartable signal
behavior.
Diffstat (limited to 'winsup/cygwin/wait.cc')
-rw-r--r--winsup/cygwin/wait.cc31
1 files changed, 17 insertions, 14 deletions
diff --git a/winsup/cygwin/wait.cc b/winsup/cygwin/wait.cc
index 2f5c1ba4e..852c7f453 100644
--- a/winsup/cygwin/wait.cc
+++ b/winsup/cygwin/wait.cc
@@ -47,11 +47,12 @@ wait3 (int *status, int options, struct rusage *r)
pid_t
wait4 (int intpid, int *status, int options, struct rusage *r)
{
- int rc;
+ int res;
waitq *w;
HANDLE waitfor;
sigframe thisframe (mainthread);
+beg:
if (options & ~(WNOHANG | WUNTRACED))
{
set_errno (EINVAL);
@@ -71,48 +72,50 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
w->pid, w->options);
if (!proc_subproc(PROC_WAIT, (DWORD)w))
{
- set_errno(ENOSYS);
+ set_errno (ENOSYS);
paranoid_printf ("proc_subproc returned 0");
- rc = -1;
+ res = -1;
goto done;
}
if ((waitfor = w->ev) == NULL)
goto nochildren;
- rc = WaitForSingleObject (waitfor, INFINITE);
+ res = WaitForSingleObject (waitfor, INFINITE);
- sigproc_printf ("%d = WaitForSingleObject (...)", rc);
+ sigproc_printf ("%d = WaitForSingleObject (...)", res);
if (w->ev == NULL)
{
nochildren:
/* found no children */
set_errno (ECHILD);
- rc = -1;
+ res = -1;
goto done;
}
if (w->status == -1)
{
set_sig_errno (EINTR);
- rc = -1;
+ res = -1;
}
- else if (rc != WAIT_OBJECT_0)
+ else if (res != WAIT_OBJECT_0)
{
/* We shouldn't set errno to any random value if we can help it.
See the Posix manual for a list of valid values for `errno'. */
set_errno (EINVAL);
- rc = -1;
+ res = -1;
}
- else if ((rc = w->pid) != 0 && status)
+ else if ((res = w->pid) != 0 && status)
*status = w->status;
done:
- sigproc_printf ("intpid %d, status %p, w->status %d, options %d, rc %d",
- intpid, status, w->status, options, rc);
+ if (res < 0 && get_errno () == EINTR && call_signal_handler ())
+ goto beg;
+ sigproc_printf ("intpid %d, status %p, w->status %d, options %d, res %d",
+ intpid, status, w->status, options, res);
w->status = -1;
- if (rc < 0)
+ if (res < 0)
sigproc_printf("*** errno = %d", get_errno());
- return rc;
+ return res;
}