[pkg-fso-commits] [SCM] Automatic Display Manager branch, master, updated. debian/0.1-52-g76526e2
Enrico Zini
enrico at enricozini.org
Mon Feb 23 18:02:49 UTC 2009
The following commit has been merged in the master branch:
commit ff36fffbcd83d05ffe0572c48c0ea21ae9418309
Author: Enrico Zini <enrico at enricozini.org>
Date: Thu Feb 19 12:04:32 2009 +0000
Redone signal handling code
diff --git a/nodm.c b/nodm.c
index 1935afd..d600074 100644
--- a/nodm.c
+++ b/nodm.c
@@ -203,6 +203,7 @@ static int run_shell (int* status)
{
int child;
sigset_t ourset;
+ struct sigaction action;
char* args[5];
char* argv0 = getenv("NODM_XINIT");
if (argv0 == NULL)
@@ -242,55 +243,62 @@ static int run_shell (int* status)
closelog ();
return 1;
}
+
/* parent only */
+
+ /* Reset caught signal flag */
+ caught = 0;
+
+ /* Block all signals */
sigfillset (&ourset);
if (sigprocmask (SIG_BLOCK, &ourset, NULL)) {
(void) fprintf (stderr, "%s: signal malfunction\n", Prog);
- caught = 1;
+ goto killed;
}
- if (!caught) {
- struct sigaction action;
-
- action.sa_handler = catch_signals;
- sigemptyset (&action.sa_mask);
- action.sa_flags = 0;
- sigemptyset (&ourset);
-
- if (sigaddset (&ourset, SIGTERM)
- || sigaddset (&ourset, SIGALRM)
- || sigaction (SIGTERM, &action, NULL)
- || sigprocmask (SIG_UNBLOCK, &ourset, NULL)
- ) {
- fprintf (stderr,
- "%s: signal masking malfunction\n", Prog);
- caught = 1;
- }
+
+ /* Catch SIGTERM and SIGALRM using 'catch_signals' */
+ action.sa_handler = catch_signals;
+ sigemptyset (&action.sa_mask);
+ action.sa_flags = 0;
+ sigemptyset (&ourset);
+
+ if (sigaddset (&ourset, SIGTERM)
+#ifdef DEBUG_NODM
+ || sigaddset (&ourset, SIGINT)
+ || sigaddset (&ourset, SIGQUIT)
+#endif
+ || sigaddset (&ourset, SIGALRM)
+ || sigaction (SIGTERM, &action, NULL)
+ || sigprocmask (SIG_UNBLOCK, &ourset, NULL)
+ ) {
+ fprintf (stderr, "%s: signal masking malfunction\n", Prog);
+ goto killed;
}
- if (!caught) {
- do {
- int pid;
+ do {
+ int pid;
- pid = waitpid (-1, status, WUNTRACED);
+ pid = waitpid (-1, status, WUNTRACED);
- if (WIFSTOPPED (*status)) {
- kill (getpid (), SIGSTOP);
- /* once we get here, we must have resumed */
- kill (pid, SIGCONT);
- }
- } while (WIFSTOPPED (*status));
- }
+ if (WIFSTOPPED (*status)) {
+ kill (getpid (), SIGSTOP);
+ /* once we get here, we must have resumed */
+ kill (pid, SIGCONT);
+ }
+ } while (WIFSTOPPED (*status));
- if (caught) {
- fprintf (stderr, "\nSession terminated, killing shell...");
- kill (child, SIGTERM);
- sleep (2);
- kill (child, SIGKILL);
- fprintf (stderr, " ...killed.\n");
- return -1;
- }
+ if (caught)
+ goto killed;
return 0;
+
+killed:
+ fprintf (stderr, "\nSession terminated, killing shell...");
+ kill (child, SIGTERM);
+ sleep (2);
+ kill (child, SIGKILL);
+ fprintf (stderr, " ...killed.\n");
+ return -1;
}
void run_session()
--
Automatic Display Manager
More information about the pkg-fso-commits
mailing list