Implement $last_pid, taking the place of %last

Set as a global variable upon the execution of a background job.
This commit is contained in:
Mahmoud Al-Qudsi 2018-03-09 08:56:13 -06:00
parent f7e0cbc7a4
commit 26cc112096

View file

@ -1149,6 +1149,7 @@ void exec_job(parser_t &parser, job_t *j) {
j->set_flag(JOB_CONSTRUCTED, true); j->set_flag(JOB_CONSTRUCTED, true);
if (!j->get_flag(JOB_FOREGROUND)) { if (!j->get_flag(JOB_FOREGROUND)) {
proc_last_bg_pid = j->pgid; proc_last_bg_pid = j->pgid;
env_set(L"last_pid", ENV_GLOBAL, { to_string(proc_last_bg_pid) });
} }
if (!exec_error) { if (!exec_error) {