Re: `jobs` within command substitution doesn't work

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

 



On Wed, 2024-10-23 at 20:46 +0100, Mike Squire wrote:
> $! will give you the PID of the most recently backgrounded process
> and
> is part of the POSIX specification.

Sure, I haven’t said it’s impossible... just "impossible to easily…".

$! get's a bit tedious if one has many jobs (or even a dynamic number)
and if one wants to check which of them still lives, one needs to
execute some other process.


> I have often seen code like "some_command & pid=$!" to background a
> task and get its PID. It also has the advantage that it only gives
> you
> the PID of the most recently backgrounded task, not a list of all
> currently backgrounded tasks (which "jobs -p" does).

It’s actually the later which I've been doing.

Still thanks :-)
Chris.





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

  Powered by Linux