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

Zsh problem with script that spawns multiple processes background.



Hi!

Im experiencing following problem. I have large Zsh script done, around
4000 lines long at the moment.

I have simple while [ ] loop like this:

$File_Mod_Init = Text file with some information
$my_cat = Precached cat command on Ramdisk

$my_cat $File_Mod_Init | while read File ; do

function FM () {

Here it does lot of things...

}

# Engine that spawns multiple sub processes is like this:

if [ ! "$filemod_procid" -eq "$filemod_threads" ] ; then

[ -z "$auth" ] && {
[ ! -z "$array_proxy" ] && {
rnd_prx
unset http_proxy && http_proxy="$prx" && export http_proxy
 }
}

# Here actual Multithread engine

FM $filemod_procid &
File_Module_Pid=$(echo $!)
Process $File_Module_Pid &
FM_Pids=( "${FM_Pids[@]}" "$File_Module_Pid" )
let "filemod_procid++"

else

wait
filemod_procid=0

fi

done

Problem is that it seem to miss about 15% of processess, they just disappear
and it wont do things inside that FM function for them. Any idea what is
the cause?

If i set above loop without any "multithreads" things works perfectly. Is
there bug somwhere in Zsh? As a reference have a look at:

http://xpkzxc.com/tutorial/ABS/debugging.html#MULTIPLEPROC

Especially part:

# ======================= SCRIPT AUTHOR'S NOTES ======================= #
#  It's not completely bug free.
#  I ran it with limit = 500 and after the first few hundred iterations,
#+ one of the concurrent threads disappeared!
#  Not sure if this is collisions from trap signals or something else.
#  Once the trap is received, there's a brief moment while executing the
#+ trap handler but before the next trap is set.  During this time, it may
#+ be possible to miss a trap signal, thus miss spawning a child process.

#  No doubt someone may spot the bug and will be writing
#+ . . . in the future.

Zsh suffers for same bug? My own maded multiprocess loop is based on this
bash one... I tried this same with latest Bash as well, same behaviour,
about 15% disappears as well :(



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