diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -1092,8 +1092,10 @@ TRACE(("waitforjob(%%%td) called\n", jp - jobtab + 1)); while (jp->state == 0) if (dowait(DOWAIT_BLOCK | (Tflag ? DOWAIT_SIG | - DOWAIT_SIG_TRAP : 0), jp) == -1) + DOWAIT_SIG_TRAP : 0), jp) == -1) { + backgndpid = jp->ps[0].pid; dotrap(); + } #if JOBS if (jp->jobctl) { if (ttyfd >= 0 && tcsetpgrp(ttyfd, rootpid) < 0)