* wait.cc (wait4): Rename variable for consistency. Allow restartable signal
behavior.
This commit is contained in:
parent
9334c89c1d
commit
9470a80c8b
@ -1,3 +1,8 @@
|
|||||||
|
Mon Jan 15 21:07:00 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* wait.cc (wait4): Rename variable for consistency. Allow restartable
|
||||||
|
signal behavior.
|
||||||
|
|
||||||
Mon Jan 15 23:15:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
Mon Jan 15 23:15:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* mmap.cc (mmap): Add more parameter checking. Change error output
|
* mmap.cc (mmap): Add more parameter checking. Change error output
|
||||||
|
@ -47,11 +47,12 @@ wait3 (int *status, int options, struct rusage *r)
|
|||||||
pid_t
|
pid_t
|
||||||
wait4 (int intpid, int *status, int options, struct rusage *r)
|
wait4 (int intpid, int *status, int options, struct rusage *r)
|
||||||
{
|
{
|
||||||
int rc;
|
int res;
|
||||||
waitq *w;
|
waitq *w;
|
||||||
HANDLE waitfor;
|
HANDLE waitfor;
|
||||||
sigframe thisframe (mainthread);
|
sigframe thisframe (mainthread);
|
||||||
|
|
||||||
|
beg:
|
||||||
if (options & ~(WNOHANG | WUNTRACED))
|
if (options & ~(WNOHANG | WUNTRACED))
|
||||||
{
|
{
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
@ -71,48 +72,50 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
|
|||||||
w->pid, w->options);
|
w->pid, w->options);
|
||||||
if (!proc_subproc(PROC_WAIT, (DWORD)w))
|
if (!proc_subproc(PROC_WAIT, (DWORD)w))
|
||||||
{
|
{
|
||||||
set_errno(ENOSYS);
|
set_errno (ENOSYS);
|
||||||
paranoid_printf ("proc_subproc returned 0");
|
paranoid_printf ("proc_subproc returned 0");
|
||||||
rc = -1;
|
res = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((waitfor = w->ev) == NULL)
|
if ((waitfor = w->ev) == NULL)
|
||||||
goto nochildren;
|
goto nochildren;
|
||||||
|
|
||||||
rc = WaitForSingleObject (waitfor, INFINITE);
|
res = WaitForSingleObject (waitfor, INFINITE);
|
||||||
|
|
||||||
sigproc_printf ("%d = WaitForSingleObject (...)", rc);
|
sigproc_printf ("%d = WaitForSingleObject (...)", res);
|
||||||
|
|
||||||
if (w->ev == NULL)
|
if (w->ev == NULL)
|
||||||
{
|
{
|
||||||
nochildren:
|
nochildren:
|
||||||
/* found no children */
|
/* found no children */
|
||||||
set_errno (ECHILD);
|
set_errno (ECHILD);
|
||||||
rc = -1;
|
res = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->status == -1)
|
if (w->status == -1)
|
||||||
{
|
{
|
||||||
set_sig_errno (EINTR);
|
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.
|
/* 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'. */
|
See the Posix manual for a list of valid values for `errno'. */
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
rc = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
else if ((rc = w->pid) != 0 && status)
|
else if ((res = w->pid) != 0 && status)
|
||||||
*status = w->status;
|
*status = w->status;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
sigproc_printf ("intpid %d, status %p, w->status %d, options %d, rc %d",
|
if (res < 0 && get_errno () == EINTR && call_signal_handler ())
|
||||||
intpid, status, w->status, options, rc);
|
goto beg;
|
||||||
|
sigproc_printf ("intpid %d, status %p, w->status %d, options %d, res %d",
|
||||||
|
intpid, status, w->status, options, res);
|
||||||
w->status = -1;
|
w->status = -1;
|
||||||
if (rc < 0)
|
if (res < 0)
|
||||||
sigproc_printf("*** errno = %d", get_errno());
|
sigproc_printf("*** errno = %d", get_errno());
|
||||||
return rc;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user