mirror of https://github.com/GNOME/gimp.git
app/main.c again... _do_ use gimp_signal_private() but force it to behave
2000-05-01 Michael Natterer <mitch@gimp.org> * app/main.c * libgimp/gimp.c: again... _do_ use gimp_signal_private() but force it to behave like signal(). While on Linux it seems to be ok to use both signal() and sigaction() (because signal() is built on top of sigaction()), doing the same on other systems is totally broken code. Thanks to Garry for pointing out this portability issue. * app/errors.c: s/vprintf/g_strdup_vprintf/ * libgimp/gimpsignal.[ch]: code formating paranoia.
This commit is contained in:
parent
2d23c38941
commit
1c1c182074
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2000-05-01 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/main.c
|
||||
* libgimp/gimp.c: again... _do_ use gimp_signal_private() but
|
||||
force it to behave like signal(). While on Linux it seems to
|
||||
be ok to use both signal() and sigaction() (because signal() is
|
||||
built on top of sigaction()), doing the same on other systems
|
||||
is totally broken code. Thanks to Garry for pointing out this
|
||||
portability issue.
|
||||
|
||||
* app/errors.c: s/vprintf/g_strdup_vprintf/
|
||||
|
||||
* libgimp/gimpsignal.[ch]: code formating paranoia.
|
||||
|
||||
Sun Apr 30 14:45:16 PDT 2000 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* configure.in
|
||||
|
|
|
@ -77,6 +77,9 @@ gimp_fatal_error (gchar *fmt, ...)
|
|||
va_start (args, fmt);
|
||||
g_print ("%s: fatal error: %s\n", prog_name, g_strdup_vprintf (fmt, args));
|
||||
va_end (args);
|
||||
|
||||
g_print ("g_on_error_query()\n");
|
||||
|
||||
g_on_error_query (prog_name);
|
||||
#else
|
||||
/* g_on_error_query doesn't do anything reasonable on Win32. */
|
||||
|
@ -101,9 +104,7 @@ gimp_terminate (gchar *fmt, ...)
|
|||
va_list args;
|
||||
|
||||
va_start (args, fmt);
|
||||
g_print ("%s terminated: ", prog_name);
|
||||
vprintf (fmt, args);
|
||||
g_print ("\n");
|
||||
g_print ("%s terminated: %s\n", prog_name, g_strdup_vprintf (fmt, args));
|
||||
va_end (args);
|
||||
|
||||
if (use_debug_handler)
|
||||
|
|
18
app/main.c
18
app/main.c
|
@ -334,15 +334,15 @@ main (int argc,
|
|||
|
||||
/* Handle some signals */
|
||||
|
||||
signal (SIGHUP, on_signal);
|
||||
signal (SIGINT, on_signal);
|
||||
signal (SIGQUIT, on_signal);
|
||||
signal (SIGABRT, on_signal);
|
||||
signal (SIGBUS, on_signal);
|
||||
signal (SIGSEGV, on_signal);
|
||||
signal (SIGPIPE, on_signal);
|
||||
signal (SIGTERM, on_signal);
|
||||
signal (SIGFPE, on_signal);
|
||||
gimp_signal_private (SIGHUP, on_signal, SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGINT, on_signal, SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGQUIT, on_signal, SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGABRT, on_signal, SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGBUS, on_signal, SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGSEGV, on_signal, SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGPIPE, on_signal, SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGTERM, on_signal, SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGFPE, on_signal, SA_RESETHAND | SA_NOMASK);
|
||||
|
||||
#ifndef __EMX__ /* OS/2 may not support SA_NOCLDSTOP -GRO */
|
||||
|
||||
|
|
|
@ -198,14 +198,22 @@ gimp_main (int argc,
|
|||
* about the program error, and offer debugging if the plug-in
|
||||
* has been built with MSVC, and the user has MSVC installed.
|
||||
*/
|
||||
signal (SIGHUP, gimp_plugin_signalhandler);
|
||||
signal (SIGINT, gimp_plugin_signalhandler);
|
||||
signal (SIGQUIT, gimp_plugin_signalhandler);
|
||||
signal (SIGBUS, gimp_plugin_signalhandler);
|
||||
signal (SIGSEGV, gimp_plugin_signalhandler);
|
||||
signal (SIGPIPE, gimp_plugin_signalhandler);
|
||||
signal (SIGTERM, gimp_plugin_signalhandler);
|
||||
signal (SIGFPE, gimp_plugin_signalhandler);
|
||||
gimp_signal_private (SIGHUP, gimp_plugin_signalhandler,
|
||||
SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGINT, gimp_plugin_signalhandler,
|
||||
SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGQUIT, gimp_plugin_signalhandler,
|
||||
SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGBUS, gimp_plugin_signalhandler,
|
||||
SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGSEGV, gimp_plugin_signalhandler,
|
||||
SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGPIPE, gimp_plugin_signalhandler,
|
||||
SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGTERM, gimp_plugin_signalhandler,
|
||||
SA_RESETHAND | SA_NOMASK);
|
||||
gimp_signal_private (SIGFPE, gimp_plugin_signalhandler,
|
||||
SA_RESETHAND | SA_NOMASK);
|
||||
#endif
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
|
||||
/**
|
||||
* gimp_signal_private:
|
||||
* @signum: selects signal to be handled see man 5 signal
|
||||
* @gimp_sighandler: handler that maps to signum. Invoked by O/S.
|
||||
* handler gets signal that caused invocation.
|
||||
* @signum: Selects signal to be handled see man 5 signal
|
||||
* @gimp_sighandler: Handler that maps to signum. Invoked by O/S.
|
||||
* Handler gets signal that caused invocation.
|
||||
* @sa_flags: preferences. OR'ed SA_<xxx>. See signal.h
|
||||
*
|
||||
* This function furnishes a workalike for signal(2) but
|
||||
|
@ -44,35 +44,42 @@
|
|||
* implementations differ in their sematics, so we need to nail down
|
||||
* exactly what we want. [austin 06.04.2000]
|
||||
*
|
||||
* Returns: a reference to a signal handling function
|
||||
* Returns: A reference to a signal handling function
|
||||
*/
|
||||
GimpRetSigType
|
||||
gimp_signal_private (gint signum, void (*gimp_sighandler)(int), gint sa_flags)
|
||||
gimp_signal_private (gint signum,
|
||||
void (* gimp_sighandler) (gint),
|
||||
gint sa_flags)
|
||||
{
|
||||
int ret;
|
||||
gint ret;
|
||||
struct sigaction sa;
|
||||
struct sigaction osa;
|
||||
|
||||
/* 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! */
|
||||
/* 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;
|
||||
/* 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
|
||||
* problems. */
|
||||
/* Mask all signals while handler runs to avoid re-entrancy
|
||||
* problems.
|
||||
*/
|
||||
sigfillset (&sa.sa_mask);
|
||||
|
||||
sa.sa_flags = sa_flags;
|
||||
|
||||
ret = sigaction (signum, &sa, &osa);
|
||||
|
||||
if (ret < 0)
|
||||
g_error ("unable to set handler for signal %d\n", signum);
|
||||
|
||||
return osa.sa_handler;
|
||||
}
|
||||
|
|
|
@ -18,21 +18,23 @@
|
|||
*
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_SIGNAL_H__
|
||||
#define __GIMP_SIGNAL_H__
|
||||
|
||||
/* A gimp-level interface to a Posix.1-compliant signal package lives here */
|
||||
/* For 1.2, this gimp-level interface mostly passes through to posix calls */
|
||||
/* without modification. Certain calls manipulate struct sigaction in */
|
||||
/* ways useful to Gimp. */
|
||||
/* A gimp-level interface to a Posix.1-compliant signal package lives here
|
||||
* For 1.2, this gimp-level interface mostly passes through to posix calls
|
||||
* without modification. Certain calls manipulate struct sigaction in
|
||||
* ways useful to Gimp.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __EMX__
|
||||
/* hope this is right for OS/2 */
|
||||
#define SA_RESTART SA_SYSV
|
||||
#endif
|
||||
|
||||
/* GimpRetSigType is a reference
|
||||
* to a (signal handler) function
|
||||
* that takes a signal ID and
|
||||
|
@ -40,21 +42,18 @@
|
|||
* signal(2) returns such references;
|
||||
* so does gimp_signal_private.
|
||||
*/
|
||||
typedef void (* GimpRetSigType) (gint);
|
||||
|
||||
typedef void (*GimpRetSigType)(gint);
|
||||
/* Internal implementation that can be DEFINEd into various flavors of
|
||||
* signal(2) lookalikes.
|
||||
*/
|
||||
GimpRetSigType gimp_signal_private (gint signum,
|
||||
void (* gimp_sighandler) (gint),
|
||||
gint sa_flags);
|
||||
|
||||
/* Internal implementation that can be */
|
||||
/* DEFINEd into various flavors of */
|
||||
/* signal(2) lookalikes. */
|
||||
|
||||
GimpRetSigType gimp_signal_private (gint signum, void (*gimp_sighandler)(int), gint sa_flags);
|
||||
|
||||
/* the gimp_signal_syscallrestart() */
|
||||
/* lookalike looks like signal(2) but */
|
||||
/* quietly requests the restarting of */
|
||||
/* system calls. Addresses #2742 */
|
||||
|
||||
# define gimp_signal_syscallrestart(x, y) gimp_signal_private ((x), (y), SA_RESTART)
|
||||
/* the gimp_signal_syscallrestart() lookalike looks like signal(2) but
|
||||
* quietly requests the restarting of system calls. Addresses #2742
|
||||
*/
|
||||
#define gimp_signal_syscallrestart(x, y) gimp_signal_private ((x), (y), SA_RESTART)
|
||||
|
||||
#endif /* __GIMP_SIGNAL_H__ */
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
|
||||
/**
|
||||
* gimp_signal_private:
|
||||
* @signum: selects signal to be handled see man 5 signal
|
||||
* @gimp_sighandler: handler that maps to signum. Invoked by O/S.
|
||||
* handler gets signal that caused invocation.
|
||||
* @signum: Selects signal to be handled see man 5 signal
|
||||
* @gimp_sighandler: Handler that maps to signum. Invoked by O/S.
|
||||
* Handler gets signal that caused invocation.
|
||||
* @sa_flags: preferences. OR'ed SA_<xxx>. See signal.h
|
||||
*
|
||||
* This function furnishes a workalike for signal(2) but
|
||||
|
@ -44,35 +44,42 @@
|
|||
* implementations differ in their sematics, so we need to nail down
|
||||
* exactly what we want. [austin 06.04.2000]
|
||||
*
|
||||
* Returns: a reference to a signal handling function
|
||||
* Returns: A reference to a signal handling function
|
||||
*/
|
||||
GimpRetSigType
|
||||
gimp_signal_private (gint signum, void (*gimp_sighandler)(int), gint sa_flags)
|
||||
gimp_signal_private (gint signum,
|
||||
void (* gimp_sighandler) (gint),
|
||||
gint sa_flags)
|
||||
{
|
||||
int ret;
|
||||
gint ret;
|
||||
struct sigaction sa;
|
||||
struct sigaction osa;
|
||||
|
||||
/* 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! */
|
||||
/* 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;
|
||||
/* 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
|
||||
* problems. */
|
||||
/* Mask all signals while handler runs to avoid re-entrancy
|
||||
* problems.
|
||||
*/
|
||||
sigfillset (&sa.sa_mask);
|
||||
|
||||
sa.sa_flags = sa_flags;
|
||||
|
||||
ret = sigaction (signum, &sa, &osa);
|
||||
|
||||
if (ret < 0)
|
||||
g_error ("unable to set handler for signal %d\n", signum);
|
||||
|
||||
return osa.sa_handler;
|
||||
}
|
||||
|
|
|
@ -18,21 +18,23 @@
|
|||
*
|
||||
* $Revision$
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_SIGNAL_H__
|
||||
#define __GIMP_SIGNAL_H__
|
||||
|
||||
/* A gimp-level interface to a Posix.1-compliant signal package lives here */
|
||||
/* For 1.2, this gimp-level interface mostly passes through to posix calls */
|
||||
/* without modification. Certain calls manipulate struct sigaction in */
|
||||
/* ways useful to Gimp. */
|
||||
/* A gimp-level interface to a Posix.1-compliant signal package lives here
|
||||
* For 1.2, this gimp-level interface mostly passes through to posix calls
|
||||
* without modification. Certain calls manipulate struct sigaction in
|
||||
* ways useful to Gimp.
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef __EMX__
|
||||
/* hope this is right for OS/2 */
|
||||
#define SA_RESTART SA_SYSV
|
||||
#endif
|
||||
|
||||
/* GimpRetSigType is a reference
|
||||
* to a (signal handler) function
|
||||
* that takes a signal ID and
|
||||
|
@ -40,21 +42,18 @@
|
|||
* signal(2) returns such references;
|
||||
* so does gimp_signal_private.
|
||||
*/
|
||||
typedef void (* GimpRetSigType) (gint);
|
||||
|
||||
typedef void (*GimpRetSigType)(gint);
|
||||
/* Internal implementation that can be DEFINEd into various flavors of
|
||||
* signal(2) lookalikes.
|
||||
*/
|
||||
GimpRetSigType gimp_signal_private (gint signum,
|
||||
void (* gimp_sighandler) (gint),
|
||||
gint sa_flags);
|
||||
|
||||
/* Internal implementation that can be */
|
||||
/* DEFINEd into various flavors of */
|
||||
/* signal(2) lookalikes. */
|
||||
|
||||
GimpRetSigType gimp_signal_private (gint signum, void (*gimp_sighandler)(int), gint sa_flags);
|
||||
|
||||
/* the gimp_signal_syscallrestart() */
|
||||
/* lookalike looks like signal(2) but */
|
||||
/* quietly requests the restarting of */
|
||||
/* system calls. Addresses #2742 */
|
||||
|
||||
# define gimp_signal_syscallrestart(x, y) gimp_signal_private ((x), (y), SA_RESTART)
|
||||
/* the gimp_signal_syscallrestart() lookalike looks like signal(2) but
|
||||
* quietly requests the restarting of system calls. Addresses #2742
|
||||
*/
|
||||
#define gimp_signal_syscallrestart(x, y) gimp_signal_private ((x), (y), SA_RESTART)
|
||||
|
||||
#endif /* __GIMP_SIGNAL_H__ */
|
||||
|
||||
|
|
Loading…
Reference in New Issue