[caption id="attachment_108499" align="alignleft" width="225"] Schneeman, Richard Schneeman.[/caption]
Every program wants to live forever. What happens when a program is forced to exit before it's done running, and why would we want to do that?
Unix Signals
Feel free to skip if you are familiar with signals.
In Unix, processes can communicate to each other with pre-defined signals. You can see a list of unix signals here. This ability to communicate is extremely important in a process oriented program. For example, the Puma webserver can add concurrency by spawning child "worker" processes. It accepts requests into a master process and then hands them off to the next available child. If the system that is running the Puma master process needs to shut down or restart, we don't simply want all current requests to be stopped in their tracks. Instead, we want the child workers to finish processing the request if they can, clean up any external connections or temporary files they may have generated, then exit. The system can safely do this by sending a signal to the parent "master" process which is then, in turn, sent to the child processes.
Continue reading %License to SIGKILL%
by Richard Schneeman via SitePoint
No comments:
Post a Comment