jobs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

trying to keep my shell scripts portable,
I am also testing on systems which use dash;
for instance, /bin/sh is dash in Ubuntu.
That's where my scripts fail because of
how the "jobs" builtin behaves.

First of all, "jobs" is not even mentioned in
http://git.kernel.org/cgit/utils/dash/dash.git/tree/src/dash.1

Some basic functionality seems to be broken.
Start three background jobs:

  $  md5sum < /dev/random &
  $  md5sum < /dev/random &
  $  md5sum < /dev/random &

What jobs am I running?

  $ jobs
  [3] + Running                    md5sum 0</dev/random
  [2] - Running                    md5sum 0</dev/random
  [1]   Running                    md5sum 0</dev/random

Good. How many is that?

  $ jobs | wc -l
  0

Zero. Hm.

  $ jobs
  [3] + Running                    md5sum 0</dev/random
  [2] - Running                    md5sum 0</dev/random
  [1]   Running                    md5sum 0</dev/random

No, wait, it's three. Let's kill them:

  $ kill `jobs -p`
  dash: 10: kill: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... 
  kill -l [exitstatus]

What's the pid list again?

  $ jobs -p
  30783
  30782
  30780


Is this intended? The behaviour descibed above can't be right.
Does the pipe or the `...` run in it's own shell (which indeed has no jobs)?
In that case, I can circumvent this with a temporary file, as in

  $ jobs > /tmp/jobs
  $ wc -l < /tmp/jobs

but doing that instead of a pipe seems backward at best.

	Jan



--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux