plug-ins/common/bz2.c plug-ins/common/gz.c plug-ins/common/mail.c

2000-11-08  Michael Natterer  <mitch@gimp.org>

	* 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.
This commit is contained in:
Michael Natterer 2000-11-08 21:58:22 +00:00 committed by Michael Natterer
parent 13dc11ad6d
commit 841c4278e2
10 changed files with 88 additions and 63 deletions

View File

@ -1,3 +1,21 @@
2000-11-08 Michael Natterer <mitch@gimp.org>
* 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 <sven@gimp.org> 2000-11-08 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/scripts/perspective-shadow.scm: fixed bug * plug-ins/script-fu/scripts/perspective-shadow.scm: fixed bug

View File

@ -95,7 +95,6 @@ void gimp_read_expect_msg (WireMessage *msg,
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
static void gimp_plugin_sigfatal_handler (gint sig_num); static void gimp_plugin_sigfatal_handler (gint sig_num);
static void gimp_plugin_sigchld_handler (gint sig_num);
#endif #endif
static gboolean gimp_plugin_io_error_handler (GIOChannel *channel, static gboolean gimp_plugin_io_error_handler (GIOChannel *channel,
GIOCondition cond, GIOCondition cond,
@ -245,7 +244,7 @@ gimp_main (int argc,
gimp_signal_private (SIGPIPE, SIG_IGN, 0); gimp_signal_private (SIGPIPE, SIG_IGN, 0);
/* Restart syscalls interrupted by SIGCHLD */ /* Restart syscalls interrupted by SIGCHLD */
gimp_signal_private (SIGCHLD, gimp_plugin_sigchld_handler, SA_RESTART); gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
#endif #endif
_readchannel = g_io_channel_unix_new (atoi (argv[2])); _readchannel = g_io_channel_unix_new (atoi (argv[2]));
@ -905,21 +904,6 @@ gimp_plugin_sigfatal_handler (gint sig_num)
gimp_quit (); 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 #endif
static gboolean static gboolean

View File

@ -260,7 +260,8 @@ save_image (gchar *filename,
gchar *ext; gchar *ext;
gchar *tmpname; gchar *tmpname;
gint pid; gint pid;
gint status; gint wpid;
gint process_status;
if (NULL == (ext = find_extension (filename))) if (NULL == (ext = find_extension (filename)))
{ {
@ -319,10 +320,11 @@ save_image (gchar *filename,
} }
#endif #endif
{ {
waitpid (pid, &status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED(status) || if ((wpid < 0)
WEXITSTATUS(status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("bz2: bzip2 exited abnormally on file %s\n", tmpname); g_message ("bz2: bzip2 exited abnormally on file %s\n", tmpname);
g_free (tmpname); g_free (tmpname);
@ -345,6 +347,7 @@ load_image (gchar *filename,
gchar *ext; gchar *ext;
gchar *tmpname; gchar *tmpname;
gint pid; gint pid;
gint wpid;
gint process_status; gint process_status;
if (NULL == (ext = find_extension (filename))) if (NULL == (ext = find_extension (filename)))
@ -397,10 +400,11 @@ load_image (gchar *filename,
} }
#endif #endif
{ {
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("bz2: bzip2 exited abnormally on file %s\n", filename); g_message ("bz2: bzip2 exited abnormally on file %s\n", filename);
g_free (tmpname); g_free (tmpname);

View File

@ -310,7 +310,8 @@ save_image (gchar *filename,
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
FILE *f; FILE *f;
gint pid; gint pid;
gint status; gint wpid;
gint process_status;
#else #else
FILE *in, *out; FILE *in, *out;
STARTUPINFO startupinfo; STARTUPINFO startupinfo;
@ -376,10 +377,11 @@ save_image (gchar *filename,
} }
else else
{ {
waitpid (pid, &status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (status) || if ((wpid < 0)
WEXITSTATUS (status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("gz: gzip exited abnormally on file %s\n", tmpname); g_message ("gz: gzip exited abnormally on file %s\n", tmpname);
g_free (tmpname); g_free (tmpname);
@ -432,6 +434,7 @@ load_image (gchar *filename,
gchar *tmpname; gchar *tmpname;
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
gint pid; gint pid;
gint wpid;
gint process_status; gint process_status;
#else #else
FILE *in, *out; FILE *in, *out;
@ -490,10 +493,11 @@ load_image (gchar *filename,
} }
else /* parent process */ else /* parent process */
{ {
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("gz: gzip exited abnormally on file %s\n", filename); g_message ("gz: gzip exited abnormally on file %s\n", filename);
g_free (tmpname); g_free (tmpname);

View File

@ -310,7 +310,8 @@ save_image (gchar *filename,
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
FILE *f; FILE *f;
gint pid; gint pid;
gint status; gint wpid;
gint process_status;
#else #else
FILE *in, *out; FILE *in, *out;
STARTUPINFO startupinfo; STARTUPINFO startupinfo;
@ -376,10 +377,11 @@ save_image (gchar *filename,
} }
else else
{ {
waitpid (pid, &status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (status) || if ((wpid < 0)
WEXITSTATUS (status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("gz: gzip exited abnormally on file %s\n", tmpname); g_message ("gz: gzip exited abnormally on file %s\n", tmpname);
g_free (tmpname); g_free (tmpname);
@ -432,6 +434,7 @@ load_image (gchar *filename,
gchar *tmpname; gchar *tmpname;
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
gint pid; gint pid;
gint wpid;
gint process_status; gint process_status;
#else #else
FILE *in, *out; FILE *in, *out;
@ -490,10 +493,11 @@ load_image (gchar *filename,
} }
else /* parent process */ else /* parent process */
{ {
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("gz: gzip exited abnormally on file %s\n", filename); g_message ("gz: gzip exited abnormally on file %s\n", filename);
g_free (tmpname); g_free (tmpname);

View File

@ -313,6 +313,7 @@ save_image (gchar *filename,
gchar *tmpname; gchar *tmpname;
gchar mailcmdline[512]; gchar mailcmdline[512];
gint pid; gint pid;
gint wpid;
gint process_status; gint process_status;
FILE *mailpipe; FILE *mailpipe;
FILE *infile; FILE *infile;
@ -401,10 +402,11 @@ save_image (gchar *filename,
} }
#endif #endif
{ {
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("mail: mail didnt work or something on file %s\n", tmpname); g_message ("mail: mail didnt work or something on file %s\n", tmpname);
g_free (tmpname); g_free (tmpname);

View File

@ -240,7 +240,7 @@ shoot (void)
gchar *xwdargv[7]; /* need a maximum of 7 arguments to xwd */ gchar *xwdargv[7]; /* need a maximum of 7 arguments to xwd */
gdouble xres, yres; gdouble xres, yres;
gint pid; gint pid;
gint wret; gint wpid;
gint status; gint status;
gint i = 0; gint i = 0;
@ -290,9 +290,9 @@ shoot (void)
#endif #endif
{ {
status = -1; status = -1;
wret = waitpid (pid, &status, 0); wpid = waitpid (pid, &status, 0);
if ((wret < 0) || !WIFEXITED (status)) if ((wpid < 0) || !WIFEXITED (status))
{ {
/* the tmpfile may have been created even if xwd failed */ /* the tmpfile may have been created even if xwd failed */
unlink (tmpname); unlink (tmpname);

View File

@ -146,6 +146,7 @@ load_image (gchar *filename,
gchar *ext = strrchr (filename, '.'); gchar *ext = strrchr (filename, '.');
gchar *tmpname; gchar *tmpname;
gint pid; gint pid;
gint wpid;
gint process_status; gint process_status;
gint p[2]; gint p[2];
@ -190,10 +191,11 @@ load_image (gchar *filename,
{ {
if (run_mode == GIMP_RUN_NONINTERACTIVE) if (run_mode == GIMP_RUN_NONINTERACTIVE)
{ {
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("url: wget exited abnormally on URL %s", filename); g_message ("url: wget exited abnormally on URL %s", filename);
g_free (tmpname); g_free (tmpname);
@ -405,10 +407,11 @@ load_image (gchar *filename,
return -1; return -1;
} }
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("url: wget exited abnormally on URL %s", filename); g_message ("url: wget exited abnormally on URL %s", filename);
g_free (tmpname); g_free (tmpname);

View File

@ -146,6 +146,7 @@ load_image (gchar *filename,
gchar *ext = strrchr (filename, '.'); gchar *ext = strrchr (filename, '.');
gchar *tmpname; gchar *tmpname;
gint pid; gint pid;
gint wpid;
gint process_status; gint process_status;
gint p[2]; gint p[2];
@ -190,10 +191,11 @@ load_image (gchar *filename,
{ {
if (run_mode == GIMP_RUN_NONINTERACTIVE) if (run_mode == GIMP_RUN_NONINTERACTIVE)
{ {
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("url: wget exited abnormally on URL %s", filename); g_message ("url: wget exited abnormally on URL %s", filename);
g_free (tmpname); g_free (tmpname);
@ -405,10 +407,11 @@ load_image (gchar *filename,
return -1; return -1;
} }
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("url: wget exited abnormally on URL %s", filename); g_message ("url: wget exited abnormally on URL %s", filename);
g_free (tmpname); g_free (tmpname);

View File

@ -146,6 +146,7 @@ load_image (gchar *filename,
gchar *ext = strrchr (filename, '.'); gchar *ext = strrchr (filename, '.');
gchar *tmpname; gchar *tmpname;
gint pid; gint pid;
gint wpid;
gint process_status; gint process_status;
gint p[2]; gint p[2];
@ -190,10 +191,11 @@ load_image (gchar *filename,
{ {
if (run_mode == GIMP_RUN_NONINTERACTIVE) if (run_mode == GIMP_RUN_NONINTERACTIVE)
{ {
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("url: wget exited abnormally on URL %s", filename); g_message ("url: wget exited abnormally on URL %s", filename);
g_free (tmpname); g_free (tmpname);
@ -405,10 +407,11 @@ load_image (gchar *filename,
return -1; return -1;
} }
waitpid (pid, &process_status, 0); wpid = waitpid (pid, &process_status, 0);
if (!WIFEXITED (process_status) || if ((wpid < 0)
WEXITSTATUS (process_status) != 0) || !WIFEXITED (process_status)
|| (WEXITSTATUS (process_status) != 0))
{ {
g_message ("url: wget exited abnormally on URL %s", filename); g_message ("url: wget exited abnormally on URL %s", filename);
g_free (tmpname); g_free (tmpname);