fixup! Fix assertion failure on job redirection error

This commit is contained in:
Mahmoud Al-Qudsi
2020-10-24 17:59:11 -05:00
parent 64671c64a1
commit 3652bcf731

View File

@@ -1049,7 +1049,7 @@ bool exec_job(parser_t &parser, const shared_ptr<job_t> &j, const io_chain_t &bl
// If exec_error then a backgrounded job would have been terminated before it was ever assigned
// a pgroup, so error out before setting last_pid.
auto pgid = j->get_pgid();
if (j->is_foreground() && pgid.has_value()) {
if (!j->is_foreground() && pgid.has_value()) {
parser.vars().set_one(L"last_pid", ENV_GLOBAL, to_string(*pgid));
}