glib-unix: New API to watch some Unix signals

This new API allows watching a few select Unix signals;
looking through the list on my system, I didn't see anything
else that I think it'd reasonable to watch.

We build on the previous patch to make the child watch helper thread
that existed on Unix handle these signals in the threaded case.
In the non-threaded case, they're just global variables.

https://bugzilla.gnome.org/show_bug.cgi?id=644941
This commit is contained in:
Colin Walters
2011-03-17 10:11:41 -04:00
parent 920899d78f
commit 549d895fa4
10 changed files with 549 additions and 76 deletions

View File

@@ -44,19 +44,23 @@
#include <glib.h>
#ifndef G_OS_UNIX
#error "This header may only be used on UNIX"
#endif
/**
* G_UNIX_ERROR:
*
* Error domain for API in the "g_unix_" namespace. Note that there
* is no exported enumeration mapping "errno". Instead, all functions
* ensure that "errno" is relevant. The code for all G_UNIX_ERROR is
* always 0, and the error message is always generated via
* is no exported enumeration mapping %errno. Instead, all functions
* ensure that %errno is relevant. The code for all #G_UNIX_ERROR is
* always %0, and the error message is always generated via
* g_strerror().
*
* It is expected that most code will not look at "errno" from these
* It is expected that most code will not look at %errno from these
* APIs. Important cases where one would want to differentiate between
* errors are already covered by existing cross-platform GLib API,
* such as e.g. GFile wrapping "ENOENT". However, it is provided for
* such as e.g. #GFile wrapping %ENOENT. However, it is provided for
* completeness, at least.
*/
#define G_UNIX_ERROR (g_unix_error_quark())
@@ -67,4 +71,12 @@ gboolean g_unix_pipe_flags (int *fds,
int flags,
GError **error);
GSource *g_unix_signal_source_new (int signum);
guint g_unix_signal_add_watch_full (int signum,
int priority,
GSourceFunc handler,
gpointer user_data,
GDestroyNotify notify);
#endif