If you kill your program the END block will not be run, unless you handled the kill signal. I think you only handle HUP, so any other terminal signal (INT, TERM, KILL etc.) will terminate your program without the END block being run. See BEGIN, UNITCHECK, CHECK, INIT and END for details.
An END code block is executed as late as possible, that is, after perl has finished running the program and just before the interpreter is being exited, even if it is exiting as a result of a die() function. (But not if it's morphing into another program via exec, or being blown out of the water by a signal--you have to trap that yourself (if you can).)
You open STDOUT and STDERR to /dev/null but then you print to STDERR and call die in various circumstances. For example, in the child the output from the print at the beginning of programExit() will go to /dev/null and will not be seen on your terminal. It might be better to open STDOUT and STDERR to a log file. You might then find why other operations are failing.
I note also that in the loop in your child you fork and both the parent and child continue to loop (the child after executing a system command). Maybe the child should exit after executing the system command or maybe the child should be using exec rather than system.
In reply to Re: END{} Subroutine not being called for Child process
by ig
in thread END{} Subroutine not being called for Child process
by SituationSoap
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |