From ab4e4200261bd8527ffe9a09de10a1b5a4f68ee2 Mon Sep 17 00:00:00 2001 From: "Garry R. Osgood" Date: Sun, 30 Apr 2000 17:47:32 +0000 Subject: [PATCH] app/main.c libgimp/gimpsignal.c [Documentation only] Patches arising from 2000-04-30 Garry R. Osgood * app/main.c * libgimp/gimpsignal.c [Documentation only] Patches arising from Tim Mooney to fix #2742 which should (hopefully) die at this point. removes on_sig_chld() from app/main() which offers no meaningful functionality in light of SA_NOCHLDSTOP. --- ChangeLog | 19 +++++++++++++++++++ app/main.c | 27 ++++++++------------------- libgimp/gimpsignal.c | 11 +++++++++-- libgimpbase/gimpsignal.c | 11 +++++++++-- 4 files changed, 45 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 235dfdaf03..8579cedb9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2000-04-30 Garry R. Osgood + * app/main.c + * libgimp/gimpsignal.c [Documentation only] + + Based on a patch and testing furnished by Tim Mooney + Retiring app/main.c + on_sig_chld(); at best this function is schizoid: On the left hand it + employs a facility for processes that have nothing better to do + than sleep until children die. (waitpid()) But it employs this + policy on the right hand, in a SIGCLD handler, a facility for + processes that have better things to do than sleep until children + die (!). And - at worse - it appeared to be contributing to the + ongoing #2742 saga. Mr. Mooney and I concur that for now asking + POSIX OS's not to generate SIGCLD at all is better than asking + mentally divided functions to handle them. Eventually we will need + SIGCLD handlers to implement runtime plug-in management (Mitch: + "gimp_nanny()") When we come to that fork in the road (;)), we + will need to work carefully so as not to re-introduce #2742. + 2000-04-30 Sven Neumann * app/gimage_cmds.c: reverted Asbjorns change (changing this file diff --git a/app/main.c b/app/main.c index 8bca87b94b..e420f51b4e 100644 --- a/app/main.c +++ b/app/main.c @@ -55,7 +55,6 @@ #include #else static void on_signal (gint); -static void on_sig_child (gint); #endif static void init (void); @@ -345,10 +344,16 @@ main (int argc, gimp_signal_syscallrestart (SIGTERM, on_signal); gimp_signal_syscallrestart (SIGFPE, on_signal); - /* Handle child exits */ +#ifndef __EMX__ /* OS/2 may not support SA_NOCLDSTOP -GRO */ - gimp_signal_syscallrestart (SIGCHLD, on_sig_child); + /* Disable child exit notification. This doesn't just block */ + /* receipt of SIGCHLD, it in fact completely disables the */ + /* generation of the signal by the OS. This behavior is */ + /* mandated by POSIX.1. */ + gimp_signal_private (SIGCHLD, NULL, SA_NOCLDSTOP); + +#endif #endif g_log_set_handler (NULL, G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL, @@ -464,20 +469,4 @@ on_signal (gint sig_num) } } -/* gimp core signal handler for death-of-child signals */ - -static void -on_sig_child (gint sig_num) -{ - gint pid; - gint status; - - while (1) - { - pid = waitpid (WAIT_ANY, &status, WNOHANG); - if (pid <= 0) - break; - } -} - #endif /* !G_OS_WIN32 */ diff --git a/libgimp/gimpsignal.c b/libgimp/gimpsignal.c index 4c2c719566..d0fdac90e0 100644 --- a/libgimp/gimpsignal.c +++ b/libgimp/gimpsignal.c @@ -53,9 +53,16 @@ gimp_signal_private (gint signum, void (*gimp_sighandler)(int), gint sa_flags) struct sigaction sa; struct sigaction osa; - /* this field is a union of sa_sighandler.sa_sighandler1 and */ - /* sa_sigaction1 - don't set both at once... */ + /* The sa_handler (mandated by POSIX.1) and sa_sigaction (a */ + /* common extension) are often implemented by the OS as members */ + /* of a union. This means you CAN NOT set both, you set one or */ + /* the other. Caveat programmer! */ + /* Passing gimp_signal_private a gimp_sighandler of NULL is not */ + /* an error, and generally results in the action for that signal */ + /* being set to SIG_DFL (default behavior). Many OSes define */ + /* SIG_DFL as (void (*)()0, so setting sa_handler to NULL is */ + /* the same thing as passing SIG_DFL to it. */ sa.sa_handler = gimp_sighandler; /* Mask all signals while handler runs to avoid re-entrancy diff --git a/libgimpbase/gimpsignal.c b/libgimpbase/gimpsignal.c index 4c2c719566..d0fdac90e0 100644 --- a/libgimpbase/gimpsignal.c +++ b/libgimpbase/gimpsignal.c @@ -53,9 +53,16 @@ gimp_signal_private (gint signum, void (*gimp_sighandler)(int), gint sa_flags) struct sigaction sa; struct sigaction osa; - /* this field is a union of sa_sighandler.sa_sighandler1 and */ - /* sa_sigaction1 - don't set both at once... */ + /* The sa_handler (mandated by POSIX.1) and sa_sigaction (a */ + /* common extension) are often implemented by the OS as members */ + /* of a union. This means you CAN NOT set both, you set one or */ + /* the other. Caveat programmer! */ + /* Passing gimp_signal_private a gimp_sighandler of NULL is not */ + /* an error, and generally results in the action for that signal */ + /* being set to SIG_DFL (default behavior). Many OSes define */ + /* SIG_DFL as (void (*)()0, so setting sa_handler to NULL is */ + /* the same thing as passing SIG_DFL to it. */ sa.sa_handler = gimp_sighandler; /* Mask all signals while handler runs to avoid re-entrancy