My script makes flock. This prevents me for runing its twice. Script can execute another script, and there is a problem. Sometimes another scripts leaves processes in background. Unfortunately they inherits flocks, I don't need this. Is it any wraper who close some file handles before execute specified executable?
I use linux debian, but it isn't impornant linux distro or version.
- My script A is run
- My script A makes flock
- My script A runs external executable B
- External B runs executable C as background (inherit flock)
- External B finishes and leaves C in background (inherit flock)
- My script A finishes because B finishes
- Another loop, My script A is run (as point 1)
- My script A makes flock and fail, because C still is running
I want exactly run external executable B with closed flocked filehandle. Flock should be keeped until only my script A is running. I don't want close flock between 2 and 3 points, because there will be "flock hole". Is there any wrapper os something like this?