diff options
author | George Lebl <jirka@5z.com> | 2002-08-23 08:29:49 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2002-08-23 08:29:49 +0000 |
commit | ce50f985f0ca818e8f132ff3afcb23c3ea37609f (patch) | |
tree | cc1ca615c047a83fe901b554482133245392b55d /gui | |
parent | 59dea77978a334b783794d1b673c752a3d7d0aab (diff) | |
download | gdm-ce50f985f0ca818e8f132ff3afcb23c3ea37609f.tar.gz |
fix subtle possible race that could kill another process and simplify code
Fri Aug 23 01:09:36 2002 George Lebl <jirka@5z.com>
* gui/gdmlogin.c: fix subtle possible race that could kill another
process and simplify code in the meantime. Ignore SIGCHLD, and
don't wait for the background process until we want to kill it,
that may leave a zombie for a little bit if the process dies early,
but who cares.
* daemon/display.c, daemon/gdm.c, daemon/misc.c, daemon/server.c,
daemon/slave.c: Fix many many very minor races but such that
could conceivably take things down (a kill (0,...) "could"
very theoretically occur previously). Fix some worse but still
not very likely races by using the push/pop of sigchld block in
places where we blocked by hand. Ensure all processes are always
killed on slave exit (probably doing things redundantly in some
cases). Fix some possible cases of syslog from a signal which
does bad things to our karma sometimes. When the server dies
make sure we don't do anything with the display (we null the d->dsp
var) to make sure we don't reenter the xioerror_handler. The
extra_process uses 0 and not -1 as the no value everywhere.
Make sure kills are never called with -1 (probably just anal,
but one never knows). Do setsid and the init in daemonize
on -nodaemon as well. Do setsid for greeter/chooser/config.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/gdmlogin.c | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/gui/gdmlogin.c b/gui/gdmlogin.c index c3939dac..d120f2d4 100644 --- a/gui/gdmlogin.c +++ b/gui/gdmlogin.c @@ -281,21 +281,12 @@ setup_cursor (GdkCursorType type) } static void -gdm_greeter_chld (int sig) -{ - if (backgroundpid != 0 && - waitpid (backgroundpid, NULL, WNOHANG) > 0) { - backgroundpid = 0; - } -} - -static void kill_thingies (void) { pid_t pid = backgroundpid; backgroundpid = 0; - if (pid != 0) { + if (pid > 0) { if (kill (pid, SIGTERM) == 0) waitpid (pid, NULL, 0); } @@ -4022,7 +4013,6 @@ main (int argc, char *argv[]) { struct sigaction hup; struct sigaction term; - struct sigaction chld; sigset_t mask; GIOChannel *ctrlch; const char *gdm_version; @@ -4212,19 +4202,12 @@ main (int argc, char *argv[]) if (sigaction (SIGTERM, &term, NULL) < 0) gdm_login_abort (_("main: Error setting up TERM signal handler")); - chld.sa_handler = gdm_greeter_chld; - chld.sa_flags = SA_RESTART; - sigemptyset(&chld.sa_mask); - sigaddset (&chld.sa_mask, SIGCHLD); - - if (sigaction (SIGCHLD, &chld, NULL) < 0) - gdm_login_abort (_("main: Error setting up CHLD signal handler")); - sigfillset (&mask); sigdelset (&mask, SIGTERM); sigdelset (&mask, SIGHUP); sigdelset (&mask, SIGINT); - sigdelset (&mask, SIGCHLD); + /* ignore SIGCHLD */ + sigaddset (&mask, SIGCHLD); if (sigprocmask (SIG_SETMASK, &mask, NULL) == -1) gdm_login_abort (_("Could not set signal mask!")); |