On Mon, 2007-12-31 at 06:49 -0800, Valery Reznic wrote: > Recently I was doing something entirely different and > was badly bitten by solution to this problem: > > Following code: > > Output=`something &` > > Will not finished until program "something" is exited. > shell in this case not used waitpid, but tried to read > from the pipe, till "something" closed it's end.
> But if one want wait to the background process to > finsish this can be solution. Its interesting - I wasn't aware of this issue (never tried something like this, but I think I would have understood what happens). The reason its not a solution to my problem is that I want to background all the processes before starting to wait on them - otherwise I wouldn't have backgrounded them in the first place. but... maybe... function startSSH() { host=$1 ssh [EMAIL PROTECTED] "sleep 3; echo 'Done waiting in $host'" } cmds= for host in 1 2; do cmds="$cmds ( startSSH ${host} & );" done echo $(eval $cmds) > /dev/null echo "all done!" This would have worked nicely - if not for the fact that like solutions based on getting the shell to background the ssh process, this one doesn't take into account that users might need to type in passwords. If I want to keep using bash then I need to use the (partial and race condition prone) pgrep solution. But porting this script to a different language, if I don't want to prompt the user for the passwords myself and to creat the ssh tunnels myself progrematically, how would I go about detecting the backgrounded ssh processes ? -- Oded ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]