I have some script using flock executable. It works well. Problem is when this script calls another script, and it creates background process. In this situation background process inherits file locked file handle, this is system behavior. I'm looking for any tool that works as wrapper and close all unneeded handles, specially for with file locks.
In my idea only main process shoud be protected against running twice. I know this is untypical sytuation. Usually all children should finish for leaving file lock, but in this situation this does not work.
At now I use some workaround, using some wrapper with main code above, but I'd preffer use some binary wrapper.
#!/bin/bash for fd in $(ls /proc/$$/fd); do case "$fd" in 0|1|2|255) ;; *) eval "exec $fd>&-" ;; esac done exec $1 $2 $3 $4 $5 $6 $7 $8 $9