On Sat, Oct 28, 2017 at 01:39:56PM +0200, Herby Voj????k wrote:
Hi,
I had to find out how to automatically deploy the backend written in Pharo, and so far it uses docker-compose stop to stop the instance (and later docker-compose up -d to get everything up again).
I noticed the stop phase takes a while and ends with status code 137. I presume it ended forcefully and not gracefully.
What is the idiomatic way to wait on SIGTERM and close the process gracefully?
Thanks, Herby
Try this: mySemaphore := OSProcess accessor forwardSigTerm. mySemaphore wait. "wait eg in a process until SIGTERM is detected" Typically you would use #forwardSigTerm to set up the signal handler, then start a Smalltalk process that waits on the semaphore and does whatever you want to do when the Unix signal is detected. You can do signal forwarding for any Unix signal, the #forwardSigTerm is just a convenience method. Dave