29 Dec 2013, 04:00
Prof_pragsmall

Dave Qorashi (5 posts)

Hi Jesse,

Question is related to page 124. (Resque details)
I wonder to know why at the last line child process is using exit! for quitting? I’m not getting why we’re not exiting just by using ‘exit’.

Thanks a lot for the great book.

07 Jan 2014, 12:58
Profile_pragsmall

Jesse Storimer (13 posts)

In the book I mention that the difference between them is that exit will run any defined at_exit handlers, while exit! will not.

The Resque worker code forks a child process for each job. At the end of a job run, it uses exit! to kill that child process immediately, avoiding any at_exit handlers because those are typically used for cleaning up when the ‘main’ process exits. If the child process were to execute those handlers, that clean up might interfere with the long-running parent process.

  You must be logged in to comment