summaryrefslogtreecommitdiff
path: root/src/fr-process.c
diff options
context:
space:
mode:
authorzhuyaliang <[email protected]>2018-11-28 12:24:44 +0800
committerraveit65 <[email protected]>2018-12-02 22:24:16 +0100
commit5eea3e1c074787c4082993e977af30644cec9775 (patch)
tree5a3a31c75b9ba899f405058605bd3b7a942c0a5b /src/fr-process.c
parentb1d6ced0335ed29c2305bb517228dff8cb8b8411 (diff)
downloadengrampa-5eea3e1c074787c4082993e977af30644cec9775.tar.bz2
engrampa-5eea3e1c074787c4082993e977af30644cec9775.tar.xz
Adding pause and start functions
change kill mode
Diffstat (limited to 'src/fr-process.c')
-rw-r--r--src/fr-process.c60
1 files changed, 57 insertions, 3 deletions
diff --git a/src/fr-process.c b/src/fr-process.c
index 7a65493..0ad5b1e 100644
--- a/src/fr-process.c
+++ b/src/fr-process.c
@@ -218,6 +218,7 @@ struct _FrProcessPrivate {
gboolean running;
gboolean stopping;
+ gboolean suspend;
gint current_command;
gint error_command; /* command that coused an error. */
@@ -333,7 +334,7 @@ fr_process_new (void)
static void fr_process_stop_priv (FrProcess *process, gboolean emit_signal);
-
+static int fr_switch_process_state (FrProcess *process);
static void
fr_process_finalize (GObject *object)
@@ -1026,8 +1027,52 @@ fr_process_start (FrProcess *process)
start_current_command (process);
}
}
-
-
+static int
+fr_close_suspend_process(FrProcess *process)
+{
+ int ret = -1;
+ g_return_val_if_fail(process != NULL, ret);
+
+ if (process->priv->suspend)
+ {
+ if (process->priv->command_pid > 0)
+ {
+ ret = killpg (process->priv->command_pid,SIGTERM);
+ ret = killpg (process->priv->command_pid,SIGCONT);
+ }
+ if(ret == 0)
+ process->priv->suspend = FALSE;
+ }
+
+ return ret;
+}
+static int
+fr_switch_process_state (FrProcess *process)
+{
+ int ret = -1;
+ g_return_val_if_fail(process != NULL, ret);
+
+ if (process->priv->stopping)
+ return ret;
+
+ if (process->priv->suspend)
+ {
+
+ if (process->priv->command_pid > 0)
+ ret = killpg (process->priv->command_pid,SIGCONT);
+ if(ret == 0)
+ process->priv->suspend = FALSE;
+ }
+ else
+ {
+ if (process->priv->command_pid > 0)
+ ret = killpg (process->priv->command_pid,SIGSTOP);
+ if(ret == 0)
+ process->priv->suspend = TRUE;
+ }
+
+ return ret;
+}
static void
fr_process_stop_priv (FrProcess *process,
gboolean emit_signal)
@@ -1075,3 +1120,12 @@ fr_process_stop (FrProcess *process)
{
fr_process_stop_priv (process, TRUE);
}
+int start_switch_state (FrProcess *process)
+{
+ return fr_switch_process_state (process);
+}
+void start_close_suspend_process(FrProcess *process)
+{
+ fr_close_suspend_process(process);
+}
+