From 40c9bda7fdf04edb6e74003079697d91856bcbf8 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 17 Jul 2020 13:33:36 -0700 Subject: [PATCH] Store the command that produced a job group in the group This will enable us to replace more uses of jobs with job groups. --- src/proc.cpp | 2 +- src/proc.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/proc.cpp b/src/proc.cpp index 9fd8810c1..a268ede63 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -293,7 +293,7 @@ void job_group_t::populate_group_for_job(job_t *job, const job_group_ref_t &prop props.wants_terminal = job->wants_job_control() && !job->from_event_handler(); props.is_internal = can_use_internal; props.job_id = can_use_internal ? -1 : acquire_job_id(); - job->group.reset(new job_group_t(props)); + job->group.reset(new job_group_t(props, job->command())); // Mark if it's foreground. job->group->set_is_foreground(!initial_bg); diff --git a/src/proc.h b/src/proc.h index 416778011..af571b092 100644 --- a/src/proc.h +++ b/src/proc.h @@ -212,6 +212,9 @@ class job_group_t { /// Get the cancel signal, or 0 if none. int get_cancel_signal() const { return cancel_signal_; } + /// \return the command which produced this job tree. + const wcstring &get_command() const { return command_; } + /// Mark that a process in this group got a signal, and so should cancel. void set_cancel_signal(int sig) { cancel_signal_ = sig; } @@ -248,6 +251,9 @@ class job_group_t { }; const properties_t props_; + // The original command which produced this job tree. + const wcstring command_; + // Whether we are in the foreground, meaning that the user is waiting for this. relaxed_atomic_bool_t is_foreground_{}; @@ -257,7 +263,8 @@ class job_group_t { // If not zero, a signal indicating cancellation. int cancel_signal_{}; - explicit job_group_t(const properties_t &props) : props_(props) {} + job_group_t(const properties_t &props, wcstring command) + : props_(props), command_(std::move(command)) {} }; /// A structure representing a single fish process. Contains variables for tracking process state