+2003-02-28 Hans Breuer <hans@breuer.org>
+
+ * glib/glib.def : updated externals, including those
+ from bug #135386
+
+ * glib/makefile.msc.in : build gatomic.c
+
+ * glibconfig.h.win32.in : removed duplicate definition
+ of G_MAXSIZE, typedef void* GPid instead of int
+
+ * tests/child-test.c glib/gmain.c :
+ applied patch from J. Ali Harlow <ali@juiblex.co.uk> to fix
+ g_child_watch implementation on win32, bug #50296
+
Fri Feb 27 22:13:22 2004 Matthias Clasen <maclas@gmx.de>
* glib/gqueue.c: Trivial doc changes.
+2003-02-28 Hans Breuer <hans@breuer.org>
+
+ * glib/glib.def : updated externals, including those
+ from bug #135386
+
+ * glib/makefile.msc.in : build gatomic.c
+
+ * glibconfig.h.win32.in : removed duplicate definition
+ of G_MAXSIZE, typedef void* GPid instead of int
+
+ * tests/child-test.c glib/gmain.c :
+ applied patch from J. Ali Harlow <ali@juiblex.co.uk> to fix
+ g_child_watch implementation on win32, bug #50296
+
Fri Feb 27 22:13:22 2004 Matthias Clasen <maclas@gmx.de>
* glib/gqueue.c: Trivial doc changes.
+2003-02-28 Hans Breuer <hans@breuer.org>
+
+ * glib/glib.def : updated externals, including those
+ from bug #135386
+
+ * glib/makefile.msc.in : build gatomic.c
+
+ * glibconfig.h.win32.in : removed duplicate definition
+ of G_MAXSIZE, typedef void* GPid instead of int
+
+ * tests/child-test.c glib/gmain.c :
+ applied patch from J. Ali Harlow <ali@juiblex.co.uk> to fix
+ g_child_watch implementation on win32, bug #50296
+
Fri Feb 27 22:13:22 2004 Matthias Clasen <maclas@gmx.de>
* glib/gqueue.c: Trivial doc changes.
+2003-02-28 Hans Breuer <hans@breuer.org>
+
+ * glib/glib.def : updated externals, including those
+ from bug #135386
+
+ * glib/makefile.msc.in : build gatomic.c
+
+ * glibconfig.h.win32.in : removed duplicate definition
+ of G_MAXSIZE, typedef void* GPid instead of int
+
+ * tests/child-test.c glib/gmain.c :
+ applied patch from J. Ali Harlow <ali@juiblex.co.uk> to fix
+ g_child_watch implementation on win32, bug #50296
+
Fri Feb 27 22:13:22 2004 Matthias Clasen <maclas@gmx.de>
* glib/gqueue.c: Trivial doc changes.
+2003-02-28 Hans Breuer <hans@breuer.org>
+
+ * glib/glib.def : updated externals, including those
+ from bug #135386
+
+ * glib/makefile.msc.in : build gatomic.c
+
+ * glibconfig.h.win32.in : removed duplicate definition
+ of G_MAXSIZE, typedef void* GPid instead of int
+
+ * tests/child-test.c glib/gmain.c :
+ applied patch from J. Ali Harlow <ali@juiblex.co.uk> to fix
+ g_child_watch implementation on win32, bug #50296
+
Fri Feb 27 22:13:22 2004 Matthias Clasen <maclas@gmx.de>
* glib/gqueue.c: Trivial doc changes.
+2003-02-28 Hans Breuer <hans@breuer.org>
+
+ * glib/glib.def : updated externals, including those
+ from bug #135386
+
+ * glib/makefile.msc.in : build gatomic.c
+
+ * glibconfig.h.win32.in : removed duplicate definition
+ of G_MAXSIZE, typedef void* GPid instead of int
+
+ * tests/child-test.c glib/gmain.c :
+ applied patch from J. Ali Harlow <ali@juiblex.co.uk> to fix
+ g_child_watch implementation on win32, bug #50296
+
Fri Feb 27 22:13:22 2004 Matthias Clasen <maclas@gmx.de>
* glib/gqueue.c: Trivial doc changes.
g_async_queue_unref
g_async_queue_unref_and_unlock
g_atexit
+ g_atomic_int_add_fallback
+ g_atomic_int_compare_and_exchange_fallback
+ g_atomic_int_exchange_and_add_fallback
+; g_atomic_int_get_fallback
+ g_atomic_pointer_compare_and_exchange_fallback
+; g_atomic_pointer_get_fallback
g_basename
g_bit_nth_lsf
g_bit_nth_msf
g_cache_new
g_cache_remove
g_cache_value_foreach
+ g_child_watch_add
+ g_child_watch_add_full
+ g_child_watch_source_new
g_clear_error
g_completion_add_items
g_completion_clear_items
g_node_child_position
g_node_children_foreach
g_node_copy
+ g_node_copy_deep
g_node_depth
g_node_destroy
g_node_find
g_queue_copy
g_queue_delete_link
g_queue_find
+ g_queue_find_custom
g_queue_foreach
g_queue_free
g_queue_get_length
g_string_sized_new
g_string_truncate
g_string_up
+ g_strip_context
g_strjoin
g_strjoinv
g_strlcat
GSource source;
GPid pid;
gint child_status;
- gint count;
- gboolean child_exited;
+#ifdef G_OS_WIN32
+ GPollFD poll;
+#else /* G_OS_WIN32 */
+ gint count;
+ gboolean child_exited;
+#endif /* G_OS_WIN32 */
};
struct _GPollRec
static GMainContext *default_main_context;
static GSList *main_contexts_without_pipe = NULL;
+#ifndef G_OS_WIN32
/* Child status monitoring code */
enum {
CHILD_WATCH_UNINITIALIZED,
};
static gint child_watch_init_state = CHILD_WATCH_UNINITIALIZED;
static gint child_watch_count = 0;
-#ifndef G_OS_WIN32
static gint child_watch_wake_up_pipe[2] = {0, 0};
-#else
-static HANDLE child_watch_wake_up_semaphore = NULL;
-#endif
+#endif /* !G_OS_WIN32 */
G_LOCK_DEFINE_STATIC (main_context_list);
static GSList *main_context_list = NULL;
/* Child watch functions */
+#ifdef G_OS_WIN32
+
+static gboolean
+g_child_watch_prepare (GSource *source,
+ gint *timeout)
+{
+ *timeout = -1;
+ return FALSE;
+}
+
+
+static gboolean
+g_child_watch_check (GSource *source)
+{
+ GChildWatchSource *child_watch_source;
+ gboolean child_exited;
+
+ child_watch_source = (GChildWatchSource *) source;
+
+ child_exited = child_watch_source->poll.revents & G_IO_IN;
+
+ if (child_exited)
+ {
+ DWORD child_status;
+
+ /*
+ * Note: We do _not_ check for the special value of STILL_ACTIVE
+ * since we know that the process has exited and doing so runs into
+ * problems if the child process "happens to return STILL_ACTIVE(259)"
+ * as Microsoft's Platform SDK puts it.
+ */
+ if (!GetExitCodeProcess (child_watch_source->pid, &child_status))
+ {
+ gchar *emsg = g_win32_error_message (GetLastError ());
+ g_warning (G_STRLOC ": GetExitCodeProcess() failed: %s", emsg);
+ g_free (emsg);
+
+ child_watch_source->child_status = -1;
+ }
+ else
+ child_watch_source->child_status = child_status;
+ }
+
+ return child_exited;
+}
+
+#else /* G_OS_WIN32 */
+
static void
check_for_child_exited (GSource *source)
{
if (child_watch_source->count < count)
{
-#ifndef G_OS_WIN32
gint child_status;
if (waitpid (child_watch_source->pid, &child_status, WNOHANG) > 0)
-#else
- DWORD child_status;
- if (GetExitCodeProcess (child_watch_source->pid, &child_status) &&
- child_status != STILL_ACTIVE)
-#endif
{
child_watch_source->child_status = child_status;
child_watch_source->child_exited = TRUE;
return (child_watch_source->count < child_watch_count);
}
+#endif /* G_OS_WIN32 */
+
static gboolean
g_child_watch_dispatch (GSource *source,
GSourceFunc callback,
return FALSE;
}
+#ifndef G_OS_WIN32
+
static void
g_child_watch_signal_handler (int signum)
{
if (child_watch_init_state == CHILD_WATCH_INITIALIZED_THREADED)
{
-#ifndef G_OS_WIN32
write (child_watch_wake_up_pipe[1], "B", 1);
-#else
- ReleaseSemaphore(child_watch_wake_up_semaphore, 1, NULL);
-#endif
}
else
{
child_watch_init_state = CHILD_WATCH_INITIALIZED_SINGLE;
-#ifndef G_OS_WIN32
signal (SIGCHLD, g_child_watch_signal_handler);
-#else
- /* FIXME: really nothing to be done ? --hb */
-#endif
}
static gpointer
poll_func = g_poll;
#endif
-#ifndef G_OS_WIN32
fds.fd = child_watch_wake_up_pipe[0];
fds.events = G_IO_IN;
-#endif
while (1)
{
gchar b[20];
GSList *list;
-#ifndef G_OS_WIN32
read (child_watch_wake_up_pipe[0], b, 20);
-#else
- WaitForSingleObject(child_watch_wake_up_semaphore, INFINITE);
-#endif
/* We were woken up. Wake up all other contexts in all other threads */
G_UNLOCK (main_context_list);
g_assert (g_thread_supported());
-#ifndef G_OS_WIN32
if (pipe (child_watch_wake_up_pipe) < 0)
g_error ("Cannot create wake up pipe: %s\n", g_strerror (errno));
fcntl (child_watch_wake_up_pipe[1], F_SETFL, O_NONBLOCK | fcntl (child_watch_wake_up_pipe[1], F_GETFL));
-#else
- child_watch_wake_up_semaphore = CreateSemaphore (NULL, 0, G_MAXINT, NULL);
-#endif
/* We create a helper thread that polls on the wakeup pipe indefinitely */
/* FIXME: Think this through for races */
if (g_thread_create (child_watch_helper_thread, NULL, FALSE, &error) == NULL)
g_error ("Cannot create a thread to monitor child exit status: %s\n", error->message);
child_watch_init_state = CHILD_WATCH_INITIALIZED_THREADED;
-#ifndef G_OS_WIN32
signal (SIGCHLD, g_child_watch_signal_handler);
-#else
- /* FIXME: really nothing to be done ? --hb */
-#endif
}
static void
}
}
+#endif /* !G_OS_WIN32 */
+
/**
* g_child_watch_source_new:
* @pid: process id of a child process to watch
GSource *source = g_source_new (&g_child_watch_funcs, sizeof (GChildWatchSource));
GChildWatchSource *child_watch_source = (GChildWatchSource *)source;
+#ifdef G_OS_WIN32
+ child_watch_source->poll.fd = (int)pid;
+ child_watch_source->poll.events = G_IO_IN;
+
+ g_source_add_poll (source, &child_watch_source->poll);
+#else /* G_OS_WIN32 */
g_child_watch_source_init ();
+#endif /* G_OS_WIN32 */
child_watch_source->pid = pid;
glib-@GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@s.lib : $(glib_OBJECTS) gnulib\gnulib.lib
lib /out:glib-@GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@s.lib $(glib_OBJECTS) gnulib\gnulib.lib
-libglib-2.0-@LT_CURRENT_MINUS_AGE@.dll : $(glib_OBJECTS) glib.def
+libglib-2.0-@LT_CURRENT_MINUS_AGE@.dll : $(glib_OBJECTS) gnulib\gnulib.lib glib.def
$(CC) $(CFLAGS) -LD -Fe$@ $(glib_OBJECTS) $(LIBICONV_LIBS) $(INTL_LIBS) \
gnulib\gnulib.lib $(DIRENT_LIBS) user32.lib advapi32.lib shell32.lib wsock32.lib $(LDFLAGS) /implib:glib-2.0.lib /def:glib.def
#define G_GSSIZE_FORMAT "i"
#define G_GSIZE_FORMAT "u"
-#define G_MAXSIZE G_MAXUINT
-
#define GPOINTER_TO_INT(p) ((gint) (p))
#define GPOINTER_TO_UINT(p) ((guint) (p))
#define G_MODULE_SUFFIX "dll"
-typedef int GPid;
+typedef void* GPid;
G_END_DECLS