Commit 6ba24da2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

libgimp/gimpsignal.[ch] don't panic, this is not another signal handling

2000-05-01  Michael Natterer  <mitch@gimp.org>

	* libgimp/gimpsignal.[ch]
	* libgimp/gimpui.c: don't panic, this is not another signal handling
	change but only a namespace cleanup to make the html documentation
	better. Also added documentation for gimp_ui_init().

2000-05-01  Michael Natterer  <mitch@gimp.org>

	* libgimp/libgimp-decl.txt
	* libgimp/libgimp-sections.txt
	* libgimp/tmpl/gimp.sgml
	* libgimp/tmpl/gimpsignal.sgml
	* libgimp/tmpl/gimpui.sgml
	* libgimp/tmpl/libgimp-unused.sgml: updated.
parent 1c1c1820
2000-05-01 Michael Natterer <mitch@gimp.org>
* libgimp/gimpsignal.[ch]
* libgimp/gimpui.c: don't panic, this is not another signal handling
change but only a namespace cleanup to make the html documentation
better. Also added documentation for gimp_ui_init().
2000-05-01 Michael Natterer <mitch@gimp.org>
* app/main.c
......
2000-05-01 Michael Natterer <mitch@gimp.org>
* libgimp/libgimp-decl.txt
* libgimp/libgimp-sections.txt
* libgimp/tmpl/gimp.sgml
* libgimp/tmpl/gimpsignal.sgml
* libgimp/tmpl/gimpui.sgml
* libgimp/tmpl/libgimp-unused.sgml: updated.
2000-04-23 Sven Neumann <sven@gimp.org>
* libgimp/tmpl/gimpsignal.sgml: new file
......
This diff is collapsed.
......@@ -37,6 +37,7 @@ gimp_gamma
gimp_install_cmap
gimp_use_xshm
gimp_color_cube
gimp_min_colors
gimp_request_wakeups
gimp_image_new
gimp_image_duplicate
......@@ -263,9 +264,10 @@ gp_request_wakeups_write
<SECTION>
<FILE>gimpsignal</FILE>
gimp_signal_syscallrestart
GimpRetSigType
SA_RESTART
GimpSignalHandlerFunc
gimp_signal_private
gimp_signal_syscallrestart
</SECTION>
<SECTION>
......
......@@ -361,6 +361,14 @@ gimp
@Returns:
<!-- ##### FUNCTION gimp_min_colors ##### -->
<para>
</para>
@Returns:
<!-- ##### FUNCTION gimp_request_wakeups ##### -->
<para>
......
......@@ -11,24 +11,26 @@ Portable signal handling.
<!-- ##### SECTION See_Also ##### -->
<para>
signal(2), signal(5 or 7), sigaction(2).
</para>
<!-- ##### MACRO gimp_signal_syscallrestart ##### -->
<!-- ##### MACRO SA_RESTART ##### -->
<para>
This is just an alias for systems which do not define SA_RESTART.
</para>
@x:
@y:
<!-- ##### USER_FUNCTION GimpRetSigType ##### -->
<!-- ##### USER_FUNCTION GimpSignalHandlerFunc ##### -->
<para>
A prototype for signal handler functions. Note that each function which
takes or returns a variable of this type also accepts or may return
special values defined by your system's signal.h header file (like
@SIG_DFL or @SIG_IGN).
</para>
@Param1:
@signum: The number of the signal. Useful if different signals are handled
by a single handler.
<!-- ##### FUNCTION gimp_signal_private ##### -->
......@@ -37,8 +39,19 @@ Portable signal handling.
</para>
@signum:
@gimp_sighandler:
@sa_flags:
@handler:
@flags:
@Returns:
<!-- ##### MACRO gimp_signal_syscallrestart ##### -->
<para>
Installs a signal handler in a way that system calls which were not finished
at the time of signal handler invocation will be silently restarted
by the system (without failing with an error of EINTR).
</para>
@signum: The number of the signal.
@handler: The signal handler.
......@@ -11,7 +11,10 @@ Common user interface functions.
<!-- ##### SECTION See_Also ##### -->
<para>
gtk_init(), gdk_set_use_xshm(), gdk_rgb_set_min_colors(),
gdk_rgb_set_install(), gdk_rgb_get_visual(), gdk_rgb_get_cmap(),
gtk_widget_set_default_visual(), gtk_widget_set_default_colormap(),
gtk_preview_set_gamma().
</para>
<!-- ##### FUNCTION gimp_ui_init ##### -->
......
<!-- ##### USER_FUNCTION RetSigType ##### -->
<para>
</para>
@Param1:
......@@ -26,10 +26,12 @@
/**
* 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.
* @sa_flags: preferences. OR'ed SA_<xxx>. See signal.h
* @signum: Selects signal to be handled see man 5 signal (or man 7 signal)
* @handler: Handler that maps to signum. Invoked by O/S.
* Handler gets signal that caused invocation. Corresponds
* to the @sa_handler field of the @sigaction struct.
* @flags: Preferences. OR'ed SA_<xxx>. See man sigaction. Corresponds
* to the @sa_flags field of the @sigaction struct.
*
* This function furnishes a workalike for signal(2) but
* which internally invokes sigaction(2) after certain
......@@ -38,18 +40,19 @@
* aid to transition and not new development: that effort
* should employ sigaction directly. [gosgood 18.04.2000]
*
* Cause handler to be run when signum is delivered. We
* Cause @handler to be run when @signum is delivered. We
* use sigaction(2) rather than signal(2) so that we can control the
* signal hander's environment completely via sa_flags: some signal(2)
* signal handler's environment completely via @flags: some signal(2)
* 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 the signal handling function which was
* active before the call to gimp_signal_private().
*/
GimpRetSigType
gimp_signal_private (gint signum,
void (* gimp_sighandler) (gint),
gint sa_flags)
GimpSignalHandlerFunc
gimp_signal_private (gint signum,
GimpSignalHandlerFunc handler,
gint flags)
{
gint ret;
struct sigaction sa;
......@@ -67,19 +70,19 @@ gimp_signal_private (gint signum,
* 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;
sa.sa_handler = handler;
/* Mask all signals while handler runs to avoid re-entrancy
* problems.
*/
sigfillset (&sa.sa_mask);
sa.sa_flags = sa_flags;
sa.sa_flags = flags;
ret = sigaction (signum, &sa, &osa);
if (ret < 0)
g_error ("unable to set handler for signal %d\n", signum);
return osa.sa_handler;
return (GimpSignalHandlerFunc) osa.sa_handler;
}
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -17,7 +17,7 @@
* Boston, MA 02111-1307, USA.
*
* $Revision$
*/
*/
#ifndef __GIMP_SIGNAL_H__
#define __GIMP_SIGNAL_H__
......@@ -28,6 +28,7 @@
*/
#include <signal.h>
#include <glib.h>
#ifdef __EMX__
......@@ -35,25 +36,22 @@
#define SA_RESTART SA_SYSV
#endif
/* GimpRetSigType is a reference
* to a (signal handler) function
* that takes a signal ID and
* returns void.
* signal(2) returns such references;
* so does gimp_signal_private.
/* GimpSignalHandlerFunc is a reference to a (signal handler) function
* that takes a signal ID and returns void.
* signal(2) returns such references; so does gimp_signal_private.
*/
typedef void (* GimpRetSigType) (gint);
typedef void (* GimpSignalHandlerFunc) (gint signum);
/* 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);
GimpSignalHandlerFunc gimp_signal_private (gint signum,
GimpSignalHandlerFunc handler,
gint 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)
#define gimp_signal_syscallrestart(signum,handler) gimp_signal_private ((signum), (handler), SA_RESTART)
#endif /* __GIMP_SIGNAL_H__ */
......@@ -20,6 +20,25 @@
#include "gimp.h"
#include "gimpui.h"
/**
* gimp_ui_init:
* @prog_name: The name of the plug-in which will be passed as argv[0] to
* gtk_init(). It's a convention to use the name of the
* executable and _not_ the PDB procedure name or something.
* @preview: #TRUE if the plug-in has some kind of preview in it's UI.
* Note that passing #TRUE is recommended also if one of the
* used GIMP Library widgets contains a preview (like the image
* menu returned by gimp_image_menu_new()).
*
* This function initializes GTK+ with gtk_init(), instructs GDK not to
* use X shared memory if The GIMP was invoked with the --no-xshm command
* line option and initializes GDK's image rendering subsystem (GdkRGB) to
* follow the GIMP main program's colormap allocation/installation policy.
*
* The GIMP's colormap policy can be determinded by the user with the
* gimprc variables @min_colors and @install_cmap.
*
*/
void
gimp_ui_init (gchar *prog_name,
gboolean preview)
......
......@@ -26,10 +26,12 @@
/**
* 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.
* @sa_flags: preferences. OR'ed SA_<xxx>. See signal.h
* @signum: Selects signal to be handled see man 5 signal (or man 7 signal)
* @handler: Handler that maps to signum. Invoked by O/S.
* Handler gets signal that caused invocation. Corresponds
* to the @sa_handler field of the @sigaction struct.
* @flags: Preferences. OR'ed SA_<xxx>. See man sigaction. Corresponds
* to the @sa_flags field of the @sigaction struct.
*
* This function furnishes a workalike for signal(2) but
* which internally invokes sigaction(2) after certain
......@@ -38,18 +40,19 @@
* aid to transition and not new development: that effort
* should employ sigaction directly. [gosgood 18.04.2000]
*
* Cause handler to be run when signum is delivered. We
* Cause @handler to be run when @signum is delivered. We
* use sigaction(2) rather than signal(2) so that we can control the
* signal hander's environment completely via sa_flags: some signal(2)
* signal handler's environment completely via @flags: some signal(2)
* 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 the signal handling function which was
* active before the call to gimp_signal_private().
*/
GimpRetSigType
gimp_signal_private (gint signum,
void (* gimp_sighandler) (gint),
gint sa_flags)
GimpSignalHandlerFunc
gimp_signal_private (gint signum,
GimpSignalHandlerFunc handler,
gint flags)
{
gint ret;
struct sigaction sa;
......@@ -67,19 +70,19 @@ gimp_signal_private (gint signum,
* 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;
sa.sa_handler = handler;
/* Mask all signals while handler runs to avoid re-entrancy
* problems.
*/
sigfillset (&sa.sa_mask);
sa.sa_flags = sa_flags;
sa.sa_flags = flags;
ret = sigaction (signum, &sa, &osa);
if (ret < 0)
g_error ("unable to set handler for signal %d\n", signum);
return osa.sa_handler;
return (GimpSignalHandlerFunc) osa.sa_handler;
}
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -17,7 +17,7 @@
* Boston, MA 02111-1307, USA.
*
* $Revision$
*/
*/
#ifndef __GIMP_SIGNAL_H__
#define __GIMP_SIGNAL_H__
......@@ -28,6 +28,7 @@
*/
#include <signal.h>
#include <glib.h>
#ifdef __EMX__
......@@ -35,25 +36,22 @@
#define SA_RESTART SA_SYSV
#endif
/* GimpRetSigType is a reference
* to a (signal handler) function
* that takes a signal ID and
* returns void.
* signal(2) returns such references;
* so does gimp_signal_private.
/* GimpSignalHandlerFunc is a reference to a (signal handler) function
* that takes a signal ID and returns void.
* signal(2) returns such references; so does gimp_signal_private.
*/
typedef void (* GimpRetSigType) (gint);
typedef void (* GimpSignalHandlerFunc) (gint signum);
/* 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);
GimpSignalHandlerFunc gimp_signal_private (gint signum,
GimpSignalHandlerFunc handler,
gint 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)
#define gimp_signal_syscallrestart(signum,handler) gimp_signal_private ((signum), (handler), SA_RESTART)
#endif /* __GIMP_SIGNAL_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment