[Gllug] Attach a command to run on completion of another process
- Tethys
tethys at gmail.com
Wed Feb 28 15:16:18 UTC 2007
On 2/28/07, Andrew Roberts <ar at nooneishere.co.uk> wrote:
> This doesn't appear to do what you want, but neither can I fully work
> out what the command does. Does anyone know how to use this?
It simply maps a jobspec to a pid, and runs a given command. Use it
like this[1]:
mrburns:~% jobs
[1]+ Running xterm &
mrburns:~% jobs -x echo Job 1 has PID %1
Job 1 has PID 10829
It's not as useful as you might hope, as the jobspec is only expanded
if it's surrounded by whitespace. Otherwise, you could do useful
things like see which file descriptors a background job had open. But
sadly it does't work:
mrburns:~% jobs -x ls -l /proc/%1/fd
ls: /proc/%1/fd: No such file or directory
You can get around it by passing the expanded PID to a trivial shell
script, but that defeats the point of the exercise somewhat.
Tet
[1] Yes, I know that in this trivial example, "jobs -l" would have sufficed.
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list