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>2005-01-11 18:31:04 +0300
committerChristopher Faylor <me@cgf.cx>2005-01-11 18:31:04 +0300
commit2380dfe14ca24fcc7ddb63feb8f7e4958c1a76ea (patch)
tree38221c0ab6a47ce8876b141458489586a7a6b635 /winsup/cygwin/sigproc.cc
parentaa67a4484ee30a61d1d12da8209308ab691f6bba (diff)
* pinfo.h (_pinfo::set_exit_state): Declare new function.
(pinfo::exit): Move here from _pinfo::exit. * sigproc.cc (child_info::sync): Use new function to set exitcode and process_state. * pinfo.cc (_pinfo::exit): Ditto. (proc_waiter): Ditto. (_pinfo::set_exit_state): Define new function. (_pinfo::dup_proc_pipe): Close handle when there is no parent process around to care about the exit value. * dcrt0.cc (dll_crt0_0): Move subproc_ready synchronization later to make sure that myself is still mapped in parent. (do_exit): Reflect movement to pinfo::exit. (__api_fatal): Ditto. * exceptions.cc (signal_exit): Ditto. * errno.cc (errmap): Map PROC_NOT_FOUND. * init.cc (dll_entry): Release myself before exiting. * sigproc.cc (proc_can_be_signalled): Set errno appropriately. (sig_send): Ditto. Also remove ill-advised test for !myself->sendsig since this is an indication of a process which is still initializating -- it is not an error. (child_info::sync): Don't set exitcode here. Assume that will happen in proc_waiter, if necessary. * spawn.cc (spawn_guts): Delay "wait_for_myself" logic until later. Don't wait at all if the process has already exited. Reflect movement to pinfo::exit.
Diffstat (limited to 'winsup/cygwin/sigproc.cc')
-rw-r--r--winsup/cygwin/sigproc.cc25
1 files changed, 12 insertions, 13 deletions
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 6ec9a2838..1f65712b6 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -170,7 +170,13 @@ proc_can_be_signalled (_pinfo *p)
if (p->sendsig != INVALID_HANDLE_VALUE)
{
if (p == myself_nowait || p == myself)
- return hwait_sig;
+ if (hwait_sig)
+ return true;
+ else
+ {
+ set_errno (EAGAIN);
+ return hwait_sig;
+ }
if (ISSTATE (p, PID_INITIALIZING) ||
(((p)->process_state & (PID_ACTIVE | PID_IN_USE)) ==
@@ -544,9 +550,6 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
sigpacket pack;
pack.wakeup = NULL;
- if (!myself->sendsig) // FIXME: This catches the exec case but what if the exec is going to fail?
- goto out;
-
bool wait_for_completion;
if (!(its_me = (p == NULL || p == myself || p == myself_nowait)))
wait_for_completion = false;
@@ -556,6 +559,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
{
sigproc_printf ("hwait_sig %p, myself->sendsig %p, exit_state %d",
hwait_sig, myself->sendsig, exit_state);
+ set_errno (EAGAIN);
goto out; // Either exiting or not yet initializing
}
if (wait_sig_inited)
@@ -601,8 +605,8 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
HANDLE hp = OpenProcess (PROCESS_DUP_HANDLE, false, dwProcessId);
if (!hp)
{
- sigproc_printf ("OpenProcess failed, %E");
__seterrno ();
+ sigproc_printf ("OpenProcess failed, %E");
goto out;
}
VerifyHandle (hp);
@@ -651,8 +655,8 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
process is exiting. */
if (!its_me)
{
- sigproc_printf ("WriteFile for pipe %p failed, %E", sendsig);
__seterrno ();
+ sigproc_printf ("WriteFile for pipe %p failed, %E", sendsig);
ForceCloseHandle (sendsig);
}
else
@@ -662,6 +666,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
else if (!hExeced)
system_printf ("error sending signal %d to pid %d, pipe handle %p, %E",
si.si_signo, p->pid, sendsig);
+ set_errno (EACCES);
}
goto out;
}
@@ -796,15 +801,9 @@ child_info::sync (pinfo& vchild, DWORD howlong)
res = true;
break;
case WAIT_OBJECT_0 + 1:
+ sigproc_printf ("process exited before subproc_ready");
if (WaitForSingleObject (subproc_ready, 0) == WAIT_OBJECT_0)
sigproc_printf ("should never happen. noticed subproc_ready after process exit");
- else
- {
- DWORD exitcode = 0;
- (void) GetExitCodeProcess (vchild.hProcess, &exitcode);
- vchild->exitcode = (exitcode & 0xff) << 8;
- sigproc_printf ("non-cygwin exit value is %p", exitcode);
- }
res = false;
break;
default: