Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Parallel backupping embedded systems...how?



On Tue, 9 Dec 2014 19:24:15 +0100
meino.cramer@xxxxxx wrote:
> If I put both tar processes into background I dont know
> how to wait correctly for the jobs end to start 7z.

If you have the fix in 33531 this is easy.  However, that's after 5.0.7.

process1 &
pid1=$!
process2 &
pid2=$!
wait $pid1
wait $pid2

It doesn't matter if they finish in the wrong order since the shell
remembers the status.

It's less easy before that, but you could use a SIGCHLD trap and the
$jobstates variable from zsh/parameter:


zmodload zsh/parameter
process1 &
process2 &
TRAPCHLD() {
   if (( ${#jobstates} == 0 && jobs_started )); then
     print Last background job edited, doing something else...
     trap -- CHLD
   fi
}


pws



Messages sorted by: Reverse Date, Date, Thread, Author