[girl] Cleanup after launching GNOME Videos on program exits
- From: Ole Aamot <ole src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [girl] Cleanup after launching GNOME Videos on program exits
- Date: Mon, 16 May 2016 20:08:10 +0000 (UTC)
commit ba969b8e5ea3daa58c11a696bdf9d608aa0aaca1
Author: Ole Aamot <oka oka no>
Date: Mon May 16 22:07:26 2016 +0200
Cleanup after launching GNOME Videos on program exits
src/Makefile.am | 2 +-
src/Makefile.in | 2 +-
src/girl-station.c | 53 ++++++++++++++++++++++++++++++++-------------------
src/girl.c | 6 +++++
4 files changed, 41 insertions(+), 22 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index fc13bad..23cdd00 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,7 +36,7 @@ girl_SOURCES = \
girl_CFLAGS = $(GIRL_CFLAGS) \
-DGIRL_DATADIR=\"$(datadir)/girl\" \
-DDATADIR=\"$(datadir)\" \
- -DGIRL_DEBUG=0 \
+ -DGIRL_DEBUG=1 \
-DGIRL_CFG \
-DGIRL_HELPER_PLAYER=\"$(GIRL_HELPER_PLAYER)\" \
-DGIRL_HELPER_RECORD=\"$(GIRL_HELPER_RECORD)\" \
diff --git a/src/Makefile.in b/src/Makefile.in
index 9bce41f..762a076 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -392,7 +392,7 @@ girl_SOURCES = \
girl_CFLAGS = $(GIRL_CFLAGS) \
-DGIRL_DATADIR=\"$(datadir)/girl\" \
-DDATADIR=\"$(datadir)\" \
- -DGIRL_DEBUG=0 \
+ -DGIRL_DEBUG=1 \
-DGIRL_CFG \
-DGIRL_HELPER_PLAYER=\"$(GIRL_HELPER_PLAYER)\" \
-DGIRL_HELPER_RECORD=\"$(GIRL_HELPER_RECORD)\" \
diff --git a/src/girl-station.c b/src/girl-station.c
index 1f7009d..b69ec35 100644
--- a/src/girl-station.c
+++ b/src/girl-station.c
@@ -68,15 +68,28 @@ void show_error(gchar * msg)
}
static void
-cb_child_watch( GPid pid,
- gint status)
+cb_child_watch_player( GPid pid,
+ gint status)
{
/* Remove timeout callback */
/* FIXME? g_source_remove(girl->timeout_id ); */
+ GIRL_DEBUG_MSG("Closing PID %i in %s", pid, __FUNCTION__);
+ /* Close pid */
+ g_spawn_close_pid( pid );
+ g_spawn_check_exit_status(status, NULL);
+}
+static void
+cb_child_watch_record( GPid pid,
+ gint status)
+{
+ /* Remove timeout callback */
+ /* FIXME? g_source_remove(girl->timeout_id ); */
+ GIRL_DEBUG_MSG("Closing PID %i in %s", pid, __FUNCTION__);
/* Close pid */
g_spawn_close_pid( pid );
+ g_spawn_check_exit_status(status, NULL);
}
static gboolean
@@ -226,41 +239,41 @@ void girl_helper_run(char *url, char *name, GirlStreamType type, GirlHelperType
G_SPAWN_SEARCH_PATH|G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL|G_SPAWN_DO_NOT_REAP_CHILD,
NULL,
NULL,
- &pid,
+ &girl->player_pid,
NULL,
NULL,
NULL,
&err);
if( ! ret )
{
- msg = g_strdup_printf(_("Failed to run %s (%i)\n"), command, pid);
+ msg = g_strdup_printf(_("Failed to run %s (%i)\n"), command, girl->player_pid);
show_error(msg);
g_free(msg);
return;
}
/* Add watch function to catch termination of the process. This function
* will clean any remnants of process. */
- g_child_watch_add( pid, (GChildWatchFunc)cb_child_watch, girl);
+ g_child_watch_add( girl->player_pid, (GChildWatchFunc)cb_child_watch_player, girl);
- girl->player_pid = pid;
+ /* girl->player_pid = pid; */
girl->player_status = GIRL_PLAYER_TRUE;
/* Install timeout fnction that will move the progress bar */
girl->timeout_id = g_timeout_add(100,(GSourceFunc)cb_timeout,girl);
/* #endif */
/* #if 0 */
ret = g_spawn_async_with_pipes( NULL, /* command */ argv, NULL,
- /* G_SPAWN_DO_NOT_REAP_CHILD */ G_SPAWN_DEFAULT, NULL,
- NULL, &pid, NULL, &out, &error, NULL );
+ G_SPAWN_DO_NOT_REAP_CHILD|G_SPAWN_DEFAULT, NULL,
+ NULL, &girl->player_pid, NULL, &out, &error, NULL );
if( ! ret )
{
- msg = g_strdup_printf(_("Failed to run %s (%i)\n"), command, pid);
+ msg = g_strdup_printf(_("Failed to run %s (%i)\n"), command, girl->player_pid);
show_error(msg);
g_free(msg);
return;
}
/* Add watch function to catch termination of the process. This function
* will clean any remnants of process. */
- g_child_watch_add( pid, (GChildWatchFunc)cb_child_watch, girl );
+ g_child_watch_add( girl->player_pid, (GChildWatchFunc)cb_child_watch_player, girl );
/* Create channels that will be used to read girl from pipes. *
#ifdef G_OS_WIN32
@@ -291,7 +304,7 @@ void girl_helper_run(char *url, char *name, GirlStreamType type, GirlHelperType
}
/* Add watch function to catch termination of the process. This function
* will clean any remnants of process. */
- g_child_watch_add( pid, (GChildWatchFunc)cb_child_watch, girl );
+ g_child_watch_add( girl->player_pid, (GChildWatchFunc)cb_child_watch_player, girl );
#endif
#endif
@@ -326,23 +339,23 @@ void girl_helper_run(char *url, char *name, GirlStreamType type, GirlHelperType
G_SPAWN_SEARCH_PATH|G_SPAWN_STDOUT_TO_DEV_NULL|G_SPAWN_STDERR_TO_DEV_NULL|G_SPAWN_DO_NOT_REAP_CHILD,
NULL,
NULL,
- &pid,
+ &girl->record_pid,
NULL,
NULL,
NULL,
&err);
if( ! ret )
{
- msg = g_strdup_printf(_("Failed to run %s (%i)\n"), command, pid);
+ msg = g_strdup_printf(_("Failed to run %s (%i)\n"), command, girl->record_pid);
show_error(msg);
g_free(msg);
return;
}
/* Add watch function to catch termination of the process. This function
* will clean any remnants of process. */
- g_child_watch_add( pid, (GChildWatchFunc)cb_child_watch, girl);
+ g_child_watch_add( girl->record_pid, (GChildWatchFunc)cb_child_watch_record, girl);
- girl->record_pid = pid;
+ /* girl->record_pid = pid; */
girl->record_status = GIRL_RECORD_TRUE;
girl_archive_new("Archive", "archive.mp3");
@@ -352,18 +365,18 @@ void girl_helper_run(char *url, char *name, GirlStreamType type, GirlHelperType
/* #endif */
/* #if 0 */
ret = g_spawn_async_with_pipes( NULL, /* command */ argv, NULL,
- /* G_SPAWN_DO_NOT_REAP_CHILD */ G_SPAWN_DEFAULT, NULL,
- NULL, &pid, NULL, &out, &error, NULL );
+ G_SPAWN_DO_NOT_REAP_CHILD|G_SPAWN_DEFAULT, NULL,
+ NULL, &girl->record_pid, NULL, &out, &error, NULL );
if( ! ret )
{
- msg = g_strdup_printf(_("Failed to run %s (%i)\n"), command, pid);
+ msg = g_strdup_printf(_("Failed to run %s (%i)\n"), command, girl->record_pid);
show_error(msg);
g_free(msg);
return;
}
/* Add watch function to catch termination of the process. This function
* will clean any remnants of process. */
- g_child_watch_add( pid, (GChildWatchFunc)cb_child_watch, girl );
+ g_child_watch_add( girl->record_pid, (GChildWatchFunc)cb_child_watch_record, girl );
/* Create channels that will be used to read girl from pipes. */
#ifdef G_OS_WIN32
out_ch = g_io_channel_win32_new_fd( out );
@@ -391,7 +404,7 @@ void girl_helper_run(char *url, char *name, GirlStreamType type, GirlHelperType
}
/* Add watch function to catch termination of the process. This function
* will clean any remnants of process. */
- g_child_watch_add( pid, (GChildWatchFunc)cb_child_watch, girl );
+ g_child_watch_add( girl->record_pid, (GChildWatchFunc)cb_child_watch_record, girl );
#endif
}
}
diff --git a/src/girl.c b/src/girl.c
index e131613..c57092e 100644
--- a/src/girl.c
+++ b/src/girl.c
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
+#include <signal.h>
#include "girl.h"
#include "girl-gui.h"
#include "girl-listener.h"
@@ -606,6 +607,11 @@ void quit_app(GtkWidget * a, gpointer user_data)
}
// stationinfo = l->data;
// girl_station_save(stationinfo, NULL, NULL, NULL, NULL, NULL, NULL);
+
+ g_spawn_close_pid(girl->record_pid);
+ g_spawn_close_pid(girl->player_pid);
+ kill(girl->player_pid,SIGQUIT);
+ kill(girl->record_pid,SIGQUIT);
gtk_main_quit();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]