glug:Re: BAsh,pid e processi...

Zingus J. Rinkle glug@genova.linux.it
Sat, 10 May 2003 20:17:34 +0200


Knock, knock, dAvid...
 The Matrix has you.
Follow the White Rabbit.

On Sat, May 10, 2003 at 07:03:22PM +0200, dAvid said:
> In uno script bash  devo mandare dei processi in background ....
> la domanda e`  come faccio ha memorizzare in una variabile
> il PID del processo che lancio in uno script bash ?

Risposta veloce:
`$!'

esempio:

proc1 &
PID1="$!"
proc2 &
PID2="$!"
maintask
kill "$PID1" "$PID2"

altro esempio:

proc1 &
PID1="$!"
proc2 &
PID2="$!"
maintask
wait "$PID1" "$PID2"

oppure:

proc1 &
proc2 &
maintask
kill %1 %2

oppure:

proc1 &
proc2 &
maintask
wait %1 %2

per maggiori informazioni:
info bash	(per informazioni su $!, etc.)
help jobs	(si noti l'opzione -x)
help kill
help wait

Buon bashing,
Zingus
-- 
  _________  +-------------------------------------------------------+
\/   _____/ /  http://as0.da.ru  http://as1.da.ru      icq:164939262 |
ZJR _____/ |  alternative mailto:zingus_at_despammed.com             |
/\______/  +-------------------------------------- Zingus J. Rinkle -+