Discussion: Attendre son enfant
Afficher un message
Vieux 08/02/2007, 19h08   #4
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Attendre son enfant

2007-02-08, 17:55(+00), David LE BOURGEOIS:
> Le 08/02/2007 à 17:21:46, Ph Ivaldi a écrit :
>> Bonjour,

>
> Bonsoir.
>
>> Existe-t-il un moyen pour forcer un processus père à ne se terminer que
>> lorsqu'un hypothétique processus enfant est terminé ?

>
> $ cat pere
> ./fils & PID=$!
> printf "waiting (pid %d) ... " "$PID"
> wait "$PID"
> printf "done ($?)\n"
>
> $ cat fils
> sleep 3
> exit 42
>
> $ ./pere
> waiting (pid 6215) ... done (42)


Oui mais:

$ cat enfant
sleep 10 & exit 12
$ cat pere
../enfant
$ ./pere
$ ps
....sleep...

Je crois que c'est ce que l'OP voulait dire, d'ou l'utilisation
d'un pipe pour attendre tous les "writers".

$ cat pere-correcte
{ blah=`./enfant 3>&1 >&4 4>&-`; } 4>&1
echo "exit status de enfant: $?"
$ time ./pere
exit status de enfant: 12
....10 seconds...

--
Stéphane
  Réponse avec citation
 
Page generated in 0,05177 seconds with 9 queries