On Fri, Nov 4, 2022 at 8:12 AM Jun T wrote: > > 548 /* is this job in the foreground of an interactive shell? */ > 549 if (mypgrp != pgrp && inforeground && > 550 (jn->gleader == pgrp || > 551 (pgrp > 1 && > 552 (kill(-pgrp, 0) == -1 && errno == ESRCH)))) { > > But why just "jn->gleader == pgrp" is enough to assume that the foreground > job has finished? > [...] > Another code that looks suspicious to me is (also in jobs.c) > > 478 if (pn->pid == jn->gleader) /* if this process is process group leader */ > 479 status = pn->status; > 480 } > > [...] > If the line 478 is replaced by > > 478 if (WIFSIGNALED(pn->status) || pn->pid == jn->gleader) > > then [2] can be killed by a single ^C. Thank you! This is the clue I needed. On line 476 is 476 signalled = WIFSIGNALED(pn->status); If we change line 550 to be 550 ((jn->gleader == pgrp && signalled) || then all three examples start working. Second patch attached, replaces the one from workers/50862. Tests pass, which is not surprising since all of this depends on signaling interactive shells, but I have no idea how to write a regression test for that.