diff options
author | Christopher Faylor <me@cgf.cx> | 2003-09-20 00:31:13 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-09-20 00:31:13 +0000 |
commit | d1fb625d2bbe16aeb77d403d62742b0240ca7024 (patch) | |
tree | 282edbea12074ba940905d8930168a69d63c3601 /winsup/cygwin/spawn.cc | |
parent | 41946df6111b6daf93518b22ca49c54544c77599 (diff) | |
download | cygnal-d1fb625d2bbe16aeb77d403d62742b0240ca7024.tar.gz cygnal-d1fb625d2bbe16aeb77d403d62742b0240ca7024.tar.bz2 cygnal-d1fb625d2bbe16aeb77d403d62742b0240ca7024.zip |
* syscalls.cc (system): Strip signal considerations from here so that they are
not inherited by a child process.
* spawn.cc (spawn_guts): Handle system() signal stuff here.
* winsup.h (_P_SYSTEM): Define.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r-- | winsup/cygwin/spawn.cc | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index b6e126b82..c66e411f4 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -1,6 +1,6 @@ /* spawn.cc - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. This file is part of Cygwin. @@ -21,8 +21,8 @@ details. */ #include "cygerrno.h" #include <sys/cygwin.h> #include "security.h" -#include "fhandler.h" #include "path.h" +#include "fhandler.h" #include "dtable.h" #include "sigproc.h" #include "cygheap.h" @@ -686,6 +686,22 @@ spawn_guts (const char * prog_arg, const char *const *argv, &si, &pi); } + + /* FIXME: There is a small race here */ + + sigset_t old_mask; + _sig_func_ptr oldint = (_sig_func_ptr) NULL; + _sig_func_ptr oldquit = (_sig_func_ptr) NULL; + if (mode == _P_SYSTEM) + { + sigset_t child_block; + oldint = signal (SIGINT, SIG_IGN); + oldquit = signal (SIGQUIT, SIG_IGN); + sigemptyset (&child_block); + sigaddset (&child_block, SIGCHLD); + (void) sigprocmask (SIG_BLOCK, &child_block, &old_mask); + } + /* Restore impersonation. In case of _P_OVERLAY this isn't allowed since it would overwrite child data. */ if (mode != _P_OVERLAY) @@ -867,7 +883,14 @@ spawn_guts (const char * prog_arg, const char *const *argv, myself->exit (res, 1); break; case _P_WAIT: + case _P_SYSTEM: waitpid (cygpid, (int *) &res, 0); + if (mode == _P_SYSTEM) + { + signal (SIGINT, oldint); + signal (SIGQUIT, oldquit); + sigprocmask (SIG_SETMASK, &old_mask, NULL); + } break; case _P_DETACH: res = 0; /* Lose all memory of this child. */ @@ -923,6 +946,7 @@ spawnve (int mode, const char *path, const char *const *argv, case _P_NOWAITO: case _P_WAIT: case _P_DETACH: + case _P_SYSTEM: subproc_init (); ret = spawn_guts (path, argv, envp, mode); if (vf) |