In JOBS = 0 config, stoppedjobs() always returns 0
Denys Vlasenko <[email protected]> Wed, 28 Jan 2026 07:05:50 +0100
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <CAK1hOcPd4Lm6ixcQ_+NG5rsA5uP4A0-oHwWQWdqj3BCyJHJE7Q@mail.gmail.com> |
Good day,
There is only one place where JOBSTOOPED can be set,
and this place is conditional on #if JOBS:
#if JOBS
if (state == JOBRUNNING)
continue;
if (WIFSTOPPED(sp->status)) {
jp->stopstatus = sp->status;
state = JOBSTOPPED;
}
#endif
There are locations where code can become simpler
for JOBS = 0 config. Example:
if (!JOBS || !jp1 || jp1->state != JOBSTOPPED)
break;
The above is always true (because jp1->state != JOBSTOPPED is).
The largest of these is:
int job_warning;
int
stoppedjobs(void)
{
struct job *jp;
int retval;
retval = 0;
if (job_warning)
goto out;
jp = curjob;
if (jp && jp->state == JOBSTOPPED) {
out2str("You have stopped jobs.\n");
job_warning = 2;
retval++;
}
out:
return retval;
}
because "if (jp && jp->state == JOBSTOPPED)"
is never taken, therefore it always returns 0,
and global "job_warning" stays 0.