sigterm

In what order should I send signals to gracefully shutdown processes?

我怕爱的太早我们不能终老 提交于 2019-12-17 03:46:38
问题 In a comment on this answer of another question, the commenter says: don’t use kill -9 unless absolutely necessary! SIGKILL can’t be trapped so the killed program can’t run any shutdown routines to e.g. erase temporary files. First try HUP (1), then INT (2), then QUIT (3) I agree in principle about SIGKILL , but the rest is news to me. Given that the default signal sent by kill is SIGTERM , I would expect it is the most-commonly expected signal for graceful shutdown of an arbitrary process.

ActiveRecord::StatementInvalid when process receives SIGTERM?

蓝咒 提交于 2019-12-14 01:25:23
问题 In my Rails app, I have a script that updates some records in the database. When I send a SIGTERM to kill the script, it occasionally receives that signal while ActiveRecord is executing a query. This leads to an ActiveRecord::StatementInvalid exception being raised. I'd like to catch StatementInvalid exceptions that occur when they're they're the result of a SIGTERM and exit the script. How can I tell that a StatementInvalid is occurring because of a signal and not for some other reason? 回答1

How to process SIGTERM signal gracefully in Java?

北城余情 提交于 2019-12-12 08:51:32
问题 Let's assume we have such a trivial daemon written in java: public class Hellow { /** * @param args the command line arguments */ public static void main(String[] args) { while(true) { // 1. do // 2. some // 3. important // 4. job // 5. sleep } } } and we daemonize it using start-stop-daemon which by default sends SIGTERM (TERM) signal on --stop Let's suppose the current step performed is #2. And at this very moment we're sending TERM signal. What happens is that the execution terminates

Java: Kill all subprocesses on unix

对着背影说爱祢 提交于 2019-12-11 09:14:19
问题 I got an application written in java which runs on Unix and starts two sub-processes (via Runtime.getRuntime().exec() ) on startup. If the application crashed for some reason, the sub processes won't get killed. Now, I added a shutdown hook which gets fired on every crash, ok so far. But I'd like to send a SIGTERM signal (or at least SIGINT) on UNIX console for every sub process of the application. I should be able to find their process IDs via ps , but I did not make it to extract the PID

handling sigterm in OSx

*爱你&永不变心* 提交于 2019-12-11 02:42:07
问题 I have console C++ application built in XCode 6 and want to add SIGTERM handler to it. There are a lot of examples, but I can't get them to work. #include <csignal> namespace { volatile std::sig_atomic_t gDone = 0; } static void term_handler(int i) { gDone = 1; } int main(int argc, const char * argv[]) { std::signal(SIGTERM, term_handler); while (!gDone); return 0; } The debugger stopped on the while statement, but the handler was not called. The same problem with this code #include <signal.h

Can R interpret a SIGINT/SIGTERM and execute a process as a result?

陌路散爱 提交于 2019-12-10 18:49:05
问题 Is there anyway to capture a SIGINT or SIGTERM from the shell in R so that I can try to execute some graceful exit code? So far, I haven't found anything in my search. 来源: https://stackoverflow.com/questions/30823237/can-r-interpret-a-sigint-sigterm-and-execute-a-process-as-a-result

pcntl_wait not interrupted by SIGTERM

限于喜欢 提交于 2019-12-10 17:26:24
问题 According to the PHP docs for pcntl_wait, The wait function suspends execution of the current process until a child has exited, or until a signal is delivered whose action is to terminate the current process or to call a signal handling function. However, when I run the following code and send SIGTERM to the parent process with kill -s SIGTERM [pid] the signal handler is only called after the child exits (i.e. I have to wait for the sleep to finish. Shouldn't pcntl_wait() be interrupted by

How much time before SIGKILL

萝らか妹 提交于 2019-12-10 03:31:54
问题 I've tryed to figure out how much time is given to an application to quit when receiving a SIGTERM, before it is send a SIGKILL ? My knowledge of these signal is very low. I've read some of it in the suggested answers on Stackoverflow but I can't get a glimpse on "approximately" how much time a process can live before being SIGTERminated. EDIT : Let's say for instance that I create a problem that purposely blocks the OS from shutting down (maybe a while(1) could do it ?) I'm looking for

How to test signal handling in RSpec, particularly handling of SIGTERM?

别说谁变了你拦得住时间么 提交于 2019-12-08 16:03:17
问题 Heroku may send a SIGTERM to your application for various reasons, so I have created a handler to take care of some cleanup in case this happens. Some googling hasn't yielded any answers or examples on how to test this in RSpec. Here's the basic code: Signal.trap('TERM') do cleanup end def cleanup puts "doing some cleanup stuff" ... exit end What's the best way to test that this cleanup method is called when the program receives a SIGTERM? 回答1: Kill yourself! Send the signal to RSpec with

Capture Heroku SIGTERM in Celery workers to shutdown worker gracefully

时光怂恿深爱的人放手 提交于 2019-12-03 16:27:30
问题 I've done a ton of research on this, and I'm surprised I haven't found a good answer to this yet anywhere. I'm running a large application on Heroku, and I have certain celery tasks that run for a very long time processing, and at the end of the task save a result. Every time I redeploy on Heroku, it sends SIGTERM (and eventually, SIGKILL) and kills my running worker. I'm trying to find a way for the worker instance to shut itself down gracefully and re-queue itself for processing later so