You would expect that the output of this Ruby script is "testament", but the forked process will die without saying anything. If the process doesn't receive 'KILL', but receives 'HUP', then the process will say the testament.
How can I ensure doing something in the process is dying? Signal 'KILL' is uncatchable, so trap
doesn't work as well.
The testament won't arrive the user.
Solution: Use Another Process
I replaced at_exit
block to a fork block with the parent process' pid. It works!
Appendix: Compatible Version
Windows doesn't support fork. Here is the equivalent code with spawn
.
(Don't you have spawn
on your UNIX platform? Use spawn-for-legacy
library.)
No comments:
Post a Comment