(Buglet) job numbers do not get re-used (sometimes)
From:
Stan Marsh
Subject:
(Buglet) job numbers do not get re-used (sometimes)
Date:
Sat, 15 Aug 2026 07:31:00 -0600
This is in the category of "not really a bug, but just annoying" and probably
also in
"It's been around for so long, that it is probably been elevated into a
feature".
The problem is that if you use ^Z a lot (as I do) to create jobs and then put
them in the
background, you end up with many jobs as displayed by the "jobs -l" command.
The problem
is that when you then create a new job, it may not get the lowest available job
number.
Repro:
$ sleep 1000 &
$ sleep 1000 &
$ sleep 1000 &
$ jobs -l
(displays 3 jobs, numbered 1, 2, 3)
$ kill %1
$ jobs -l
(displays 2 jobs, numbered 2, 3)
$ sleep 1000 &
$ jobs -l
(displays 3 jobs, numbered 2, 3, 4)
$
And, in fact, you can't get a new job to be numbered #1 again unless/until you
get rid of
all of them and start over.
I find this annoying because if job #1 exits for some reason (including my
accidentally
killing it), I can't get things back to the way they were before (other than by
getting
rid of all the jobs and starting over). In particular, this means I have to
re-train
myself to refer to the new job as %4, when I had been used to referring to it
as %1.
I would like to see this fixed.
=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.
When responding to my posts, please try to refrain from giving bureaucratic
answers. If you have nothing useful to say, then just click Next and go on.