@@ -32,19 +32,19 @@ public abstract class AsyncTask : GLib.Object{
3232
3333 private string err_line = " " ;
3434 private string out_line = " " ;
35- private DataOutputStream dos_in;
36- private DataInputStream dis_out;
37- private DataInputStream dis_err;
38- protected DataOutputStream dos_log;
35+ private DataOutputStream dos_in = null ;
36+ private DataInputStream dis_out = null ;
37+ private DataInputStream dis_err = null ;
38+ protected DataOutputStream dos_log = null ;
3939 protected bool is_terminated = false ;
4040
4141 private bool stdout_is_open = false ;
4242 private bool stderr_is_open = false ;
43-
44- protected Pid child_pid;
45- private int input_fd;
46- private int output_fd;
47- private int error_fd;
43+
44+ protected Pid child_pid = 0 ;
45+ private int input_fd = - 1 ;
46+ private int output_fd = - 1 ;
47+ private int error_fd = - 1 ;
4848 private bool finish_called = false ;
4949
5050 protected string script_file = " " ;
@@ -54,7 +54,7 @@ public abstract class AsyncTask : GLib.Object{
5454 public bool background_mode = false ;
5555
5656 // public
57- public AppStatus status;
57+ public AppStatus status = AppStatus . NOT_STARTED ;
5858
5959 private string _status_line = " " ;
6060 public GLib . Mutex status_line_mutex;
@@ -69,8 +69,7 @@ public abstract class AsyncTask : GLib.Object{
6969 public int64 prg_bytes = 0 ;
7070 public int64 prg_bytes_total = 0 ;
7171 public string eta = " " ;
72- // public bool is_running = false;
73-
72+
7473 // signals
7574 public signal void stdout_line_read (string line );
7675 public signal void stderr_line_read (string line );
@@ -103,12 +102,10 @@ public abstract class AsyncTask : GLib.Object{
103102 }
104103
105104 protected AsyncTask (){
106-
107105 working_dir = TEMP_DIR + " /" + timestamp_for_path();
108106 script_file = path_combine(working_dir, " script.sh" );
109107 log_file = path_combine(working_dir, " task.log" );
110108
111- // regex = new Gee.HashMap<string,Regex>(); // needs to be initialized again in instance constructor
112109 status_line_mutex = GLib . Mutex ();
113110
114111 dir_create(working_dir);
@@ -368,12 +365,14 @@ public abstract class AsyncTask : GLib.Object{
368365 // public actions --------------
369366
370367 public void stop (AppStatus status_to_update = AppStatus .CANCELLED ) {
371-
372368 status = status_to_update;
373-
374- process_quit(child_pid);
375-
376- log_debug(" process_quit: %d " . printf(child_pid));
369+
370+ if (0 != child_pid) {
371+ process_quit(child_pid);
372+ child_pid = 0 ;
373+
374+ log_debug(" process_quit: %d " . printf(child_pid));
375+ }
377376 }
378377
379378 public void set_priority () {
0 commit comments