diff --git a/ChangeLog b/ChangeLog index e944e57cb6..17cd4c605f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2000-11-08 Michael Natterer + + * plug-ins/common/bz2.c + * plug-ins/common/gz.c + * plug-ins/common/mail.c + * plug-ins/common/screenshot.c + * plug-ins/common/url.c: applied a (modified) version of + gimp-quinet-20001108-1.patch which adds proper checking of the + return value of waitpid(). Removed the lines adding + gimp_signal_private() because of the fix below. + + * libgimp/gimp.c: Don't install a SIGCHLD signal handler but simply + call gimp_signal_private(SIGCHLD, SIG_DFL, SA_RESTART) instead. + + This is IMHO the right thing to do because the reason for the + introducion of the signal handler was the SA_RESTART feature + and not the handler itself. + 2000-11-08 Sven Neumann * plug-ins/script-fu/scripts/perspective-shadow.scm: fixed bug diff --git a/libgimp/gimp.c b/libgimp/gimp.c index 47d79020ff..a30cf04d69 100644 --- a/libgimp/gimp.c +++ b/libgimp/gimp.c @@ -95,7 +95,6 @@ void gimp_read_expect_msg (WireMessage *msg, #ifndef G_OS_WIN32 static void gimp_plugin_sigfatal_handler (gint sig_num); -static void gimp_plugin_sigchld_handler (gint sig_num); #endif static gboolean gimp_plugin_io_error_handler (GIOChannel *channel, GIOCondition cond, @@ -245,7 +244,7 @@ gimp_main (int argc, gimp_signal_private (SIGPIPE, SIG_IGN, 0); /* Restart syscalls interrupted by SIGCHLD */ - gimp_signal_private (SIGCHLD, gimp_plugin_sigchld_handler, SA_RESTART); + gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART); #endif _readchannel = g_io_channel_unix_new (atoi (argv[2])); @@ -905,21 +904,6 @@ gimp_plugin_sigfatal_handler (gint sig_num) gimp_quit (); } - -static void -gimp_plugin_sigchld_handler (gint sig_num) -{ - gint pid; - gint status; - - while (TRUE) - { - pid = waitpid (WAIT_ANY, &status, WNOHANG); - - if (pid <= 0) - break; - } -} #endif static gboolean diff --git a/plug-ins/common/bz2.c b/plug-ins/common/bz2.c index bc34d8cfb5..01e9245ff3 100644 --- a/plug-ins/common/bz2.c +++ b/plug-ins/common/bz2.c @@ -260,7 +260,8 @@ save_image (gchar *filename, gchar *ext; gchar *tmpname; gint pid; - gint status; + gint wpid; + gint process_status; if (NULL == (ext = find_extension (filename))) { @@ -319,10 +320,11 @@ save_image (gchar *filename, } #endif { - waitpid (pid, &status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED(status) || - WEXITSTATUS(status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("bz2: bzip2 exited abnormally on file %s\n", tmpname); g_free (tmpname); @@ -345,6 +347,7 @@ load_image (gchar *filename, gchar *ext; gchar *tmpname; gint pid; + gint wpid; gint process_status; if (NULL == (ext = find_extension (filename))) @@ -397,10 +400,11 @@ load_image (gchar *filename, } #endif { - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("bz2: bzip2 exited abnormally on file %s\n", filename); g_free (tmpname); diff --git a/plug-ins/common/compressor.c b/plug-ins/common/compressor.c index 9f350cfe19..089d41260c 100644 --- a/plug-ins/common/compressor.c +++ b/plug-ins/common/compressor.c @@ -310,7 +310,8 @@ save_image (gchar *filename, #ifndef G_OS_WIN32 FILE *f; gint pid; - gint status; + gint wpid; + gint process_status; #else FILE *in, *out; STARTUPINFO startupinfo; @@ -376,10 +377,11 @@ save_image (gchar *filename, } else { - waitpid (pid, &status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (status) || - WEXITSTATUS (status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("gz: gzip exited abnormally on file %s\n", tmpname); g_free (tmpname); @@ -432,6 +434,7 @@ load_image (gchar *filename, gchar *tmpname; #ifndef G_OS_WIN32 gint pid; + gint wpid; gint process_status; #else FILE *in, *out; @@ -490,10 +493,11 @@ load_image (gchar *filename, } else /* parent process */ { - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("gz: gzip exited abnormally on file %s\n", filename); g_free (tmpname); diff --git a/plug-ins/common/gz.c b/plug-ins/common/gz.c index 9f350cfe19..089d41260c 100644 --- a/plug-ins/common/gz.c +++ b/plug-ins/common/gz.c @@ -310,7 +310,8 @@ save_image (gchar *filename, #ifndef G_OS_WIN32 FILE *f; gint pid; - gint status; + gint wpid; + gint process_status; #else FILE *in, *out; STARTUPINFO startupinfo; @@ -376,10 +377,11 @@ save_image (gchar *filename, } else { - waitpid (pid, &status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (status) || - WEXITSTATUS (status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("gz: gzip exited abnormally on file %s\n", tmpname); g_free (tmpname); @@ -432,6 +434,7 @@ load_image (gchar *filename, gchar *tmpname; #ifndef G_OS_WIN32 gint pid; + gint wpid; gint process_status; #else FILE *in, *out; @@ -490,10 +493,11 @@ load_image (gchar *filename, } else /* parent process */ { - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("gz: gzip exited abnormally on file %s\n", filename); g_free (tmpname); diff --git a/plug-ins/common/mail.c b/plug-ins/common/mail.c index 9bce3731e2..8be6cfb18d 100644 --- a/plug-ins/common/mail.c +++ b/plug-ins/common/mail.c @@ -313,6 +313,7 @@ save_image (gchar *filename, gchar *tmpname; gchar mailcmdline[512]; gint pid; + gint wpid; gint process_status; FILE *mailpipe; FILE *infile; @@ -401,10 +402,11 @@ save_image (gchar *filename, } #endif { - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("mail: mail didnt work or something on file %s\n", tmpname); g_free (tmpname); diff --git a/plug-ins/common/screenshot.c b/plug-ins/common/screenshot.c index 51e88e46be..635ce32d21 100644 --- a/plug-ins/common/screenshot.c +++ b/plug-ins/common/screenshot.c @@ -240,7 +240,7 @@ shoot (void) gchar *xwdargv[7]; /* need a maximum of 7 arguments to xwd */ gdouble xres, yres; gint pid; - gint wret; + gint wpid; gint status; gint i = 0; @@ -290,9 +290,9 @@ shoot (void) #endif { status = -1; - wret = waitpid (pid, &status, 0); - - if ((wret < 0) || !WIFEXITED (status)) + wpid = waitpid (pid, &status, 0); + + if ((wpid < 0) || !WIFEXITED (status)) { /* the tmpfile may have been created even if xwd failed */ unlink (tmpname); diff --git a/plug-ins/common/url.c b/plug-ins/common/url.c index feb02b7c89..426d22f17d 100644 --- a/plug-ins/common/url.c +++ b/plug-ins/common/url.c @@ -146,6 +146,7 @@ load_image (gchar *filename, gchar *ext = strrchr (filename, '.'); gchar *tmpname; gint pid; + gint wpid; gint process_status; gint p[2]; @@ -190,10 +191,11 @@ load_image (gchar *filename, { if (run_mode == GIMP_RUN_NONINTERACTIVE) { - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("url: wget exited abnormally on URL %s", filename); g_free (tmpname); @@ -405,10 +407,11 @@ load_image (gchar *filename, return -1; } - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("url: wget exited abnormally on URL %s", filename); g_free (tmpname); diff --git a/plug-ins/uri/uri-backend-wget.c b/plug-ins/uri/uri-backend-wget.c index feb02b7c89..426d22f17d 100644 --- a/plug-ins/uri/uri-backend-wget.c +++ b/plug-ins/uri/uri-backend-wget.c @@ -146,6 +146,7 @@ load_image (gchar *filename, gchar *ext = strrchr (filename, '.'); gchar *tmpname; gint pid; + gint wpid; gint process_status; gint p[2]; @@ -190,10 +191,11 @@ load_image (gchar *filename, { if (run_mode == GIMP_RUN_NONINTERACTIVE) { - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("url: wget exited abnormally on URL %s", filename); g_free (tmpname); @@ -405,10 +407,11 @@ load_image (gchar *filename, return -1; } - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("url: wget exited abnormally on URL %s", filename); g_free (tmpname); diff --git a/plug-ins/uri/uri.c b/plug-ins/uri/uri.c index feb02b7c89..426d22f17d 100644 --- a/plug-ins/uri/uri.c +++ b/plug-ins/uri/uri.c @@ -146,6 +146,7 @@ load_image (gchar *filename, gchar *ext = strrchr (filename, '.'); gchar *tmpname; gint pid; + gint wpid; gint process_status; gint p[2]; @@ -190,10 +191,11 @@ load_image (gchar *filename, { if (run_mode == GIMP_RUN_NONINTERACTIVE) { - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("url: wget exited abnormally on URL %s", filename); g_free (tmpname); @@ -405,10 +407,11 @@ load_image (gchar *filename, return -1; } - waitpid (pid, &process_status, 0); + wpid = waitpid (pid, &process_status, 0); - if (!WIFEXITED (process_status) || - WEXITSTATUS (process_status) != 0) + if ((wpid < 0) + || !WIFEXITED (process_status) + || (WEXITSTATUS (process_status) != 0)) { g_message ("url: wget exited abnormally on URL %s", filename); g_free (tmpname);