Skip to content

only kill a task if its pid is set #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions src/Utility/AsyncTask.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ public abstract class AsyncTask : GLib.Object{

private string err_line = "";
private string out_line = "";
private DataOutputStream dos_in;
private DataInputStream dis_out;
private DataInputStream dis_err;
protected DataOutputStream dos_log;
private DataOutputStream dos_in = null;
private DataInputStream dis_out = null;
private DataInputStream dis_err = null;
protected DataOutputStream dos_log = null;
protected bool is_terminated = false;

private bool stdout_is_open = false;
private bool stderr_is_open = false;
protected Pid child_pid;
private int input_fd;
private int output_fd;
private int error_fd;

protected Pid child_pid = 0;
private int input_fd = -1;
private int output_fd = -1;
private int error_fd = -1;
private bool finish_called = false;

protected string script_file = "";
Expand All @@ -54,7 +54,7 @@ public abstract class AsyncTask : GLib.Object{
public bool background_mode = false;

// public
public AppStatus status;
public AppStatus status = AppStatus.NOT_STARTED;

private string _status_line = "";
public GLib.Mutex status_line_mutex;
Expand All @@ -69,8 +69,7 @@ public abstract class AsyncTask : GLib.Object{
public int64 prg_bytes = 0;
public int64 prg_bytes_total = 0;
public string eta = "";
//public bool is_running = false;


// signals
public signal void stdout_line_read(string line);
public signal void stderr_line_read(string line);
Expand Down Expand Up @@ -103,12 +102,10 @@ public abstract class AsyncTask : GLib.Object{
}

protected AsyncTask(){

working_dir = TEMP_DIR + "/" + timestamp_for_path();
script_file = path_combine(working_dir, "script.sh");
log_file = path_combine(working_dir, "task.log");

//regex = new Gee.HashMap<string,Regex>(); // needs to be initialized again in instance constructor
status_line_mutex = GLib.Mutex();

dir_create(working_dir);
Expand Down Expand Up @@ -368,12 +365,14 @@ public abstract class AsyncTask : GLib.Object{
// public actions --------------

public void stop(AppStatus status_to_update = AppStatus.CANCELLED) {

status = status_to_update;

process_quit(child_pid);

log_debug("process_quit: %d".printf(child_pid));

if(0 != child_pid) {
process_quit(child_pid);
child_pid = 0;

log_debug("process_quit: %d".printf(child_pid));
}
}

public void set_priority() {
Expand Down
5 changes: 0 additions & 5 deletions src/Utility/RsyncTask.vala
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,6 @@ public class RsyncTask : AsyncTask{
log_debug(string.nfill(70,'='));*/

begin();

if (status == AppStatus.RUNNING){


}
}

public override void parse_stdout_line(string out_line){
Expand Down
Loading