diff options
Diffstat (limited to 'src/proclist.c')
-rw-r--r-- | src/proclist.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/proclist.c b/src/proclist.c index 55441ac..4fb406f 100644 --- a/src/proclist.c +++ b/src/proclist.c @@ -1,11 +1,11 @@ /* proclist.c This file is part of GNU Anubis. - Copyright (C) 2005-2014 The Anubis Team. + Copyright (C) 2005-2024 The Anubis Team. GNU Anubis is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. @@ -102,19 +102,18 @@ proclist_cleanup (void (*fun) (size_t, pid_t, int)) } sigprocmask (SIG_UNBLOCK, &blockset, NULL); return count; } /* SIGCHLD handler. */ -static RETSIGTYPE +static void sig_child (int code) { struct process_status ps; while ((ps.pid = waitpid (-1, &ps.status, WNOHANG)) > 0) list_iterate (process_list, update_process_status, &ps); - signal (code, sig_child); } /* Register `pid' in the database. */ void proclist_register (pid_t pid) { @@ -128,14 +127,20 @@ proclist_register (pid_t pid) } /* Initialize the process database */ void proclist_init () { + struct sigaction act; + + act.sa_handler = sig_child; + sigemptyset (&act.sa_mask); + act.sa_flags = 0; + sigaction (SIGCHLD, &act, NULL); + process_list = list_create (); - signal (SIGCHLD, sig_child); } /* Return the number of entries resident in the database. */ size_t proclist_count () { |