Trapping Signals Sent from Other Apps
Our two example apps, db_backup.rb and todo, are not long-running apps. They start up very quickly and exit when they’re done. While this is very common for command-line apps, there are occasions where we will need to write a long-running process. You may have a process that runs all the time, polling a message queue for work to do, or you may need to run a process that monitors other processes. Or, you might have a task that just takes a long time. In each case, you’ll want a way for a user to send information to your running app.
The most common example is to stop an app from running. We do this all the time by hitting Ctrl-C when an app is running in our terminal. This actually sends the app a signal ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access