[gthumb] script: fixed task cancellation when using a shell script
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] script: fixed task cancellation when using a shell script
- Date: Sun, 1 Mar 2020 11:34:19 +0000 (UTC)
commit a1afc2f315ef2cfd8da36beeb05e1c5eff4b918e
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Feb 22 08:14:46 2020 +0100
script: fixed task cancellation when using a shell script
Kill the process group to stop the shell subprocess as well.
extensions/list_tools/gth-script-task.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/extensions/list_tools/gth-script-task.c b/extensions/list_tools/gth-script-task.c
index ed689e84..7a49db5c 100644
--- a/extensions/list_tools/gth-script-task.c
+++ b/extensions/list_tools/gth-script-task.c
@@ -95,6 +95,20 @@ watch_script_cb (GPid pid,
}
+static void
+child_setup (gpointer user_data)
+{
+ /* detach from the tty */
+
+ setsid ();
+
+ /* create a process group to kill all the child processes when
+ * canceling the operation. */
+
+ setpgid (0, 0);
+}
+
+
static void
_gth_script_task_exec (GthScriptTask *self)
{
@@ -155,7 +169,7 @@ _gth_script_task_exec (GthScriptTask *self)
argv,
NULL,
G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
- NULL,
+ child_setup,
NULL,
&self->priv->pid,
&error))
@@ -251,7 +265,7 @@ gth_script_task_cancelled (GthTask *task)
self = GTH_SCRIPT_TASK (task);
if (self->priv->pid != 0)
- kill (self->priv->pid, SIGTERM);
+ killpg (self->priv->pid, SIGTERM);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]