SIGTERM is one of the POSIX mandated signals; it indicates that the process should terminate, which is also the default action for SIGTERM.
Questions tagged [sigterm]
238 questions
319
votes
10 answers
How to process SIGTERM signal gracefully?
Let's assume we have such a trivial daemon written in python:
def mainloop():
while True:
# 1. do
# 2. some
# 3. important
# 4. job
# 5. sleep
mainloop()
and we daemonize it using start-stop-daemon which…

zerkms
- 249,484
- 69
- 436
- 539
282
votes
11 answers
Is it possible to capture a Ctrl+C signal (SIGINT) and run a cleanup function, in a "defer" fashion?
I want to capture the Ctrl+C (SIGINT) signal sent from the console and print out some partial run totals.

Sebastián Grignoli
- 32,444
- 17
- 71
- 86
115
votes
7 answers
In what order should I send signals to gracefully shutdown processes?
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…

system PAUSE
- 37,082
- 20
- 62
- 59
92
votes
3 answers
How to handle a SIGTERM
Is there a way in Java to handle a received SIGTERM?

Martijn Courteaux
- 67,591
- 47
- 198
- 287
60
votes
9 answers
Apache server keeps crashing, "caught SIGTERM, shutting down"
This just started happening three weeks or so ago. The content of my website hasn't changed, it's just a phpBB forum using MySQL as a back end.
Nothing has changed in well over a year but recently, every two days or so, the server just shuts down…

Tom
- 4,467
- 17
- 59
- 91
47
votes
3 answers
Python: What is the default handling of SIGTERM?
What does Python do under the covers by default if it receives a SIGTERM but there is no signal handler registered for it?

meteoritepanama
- 6,092
- 14
- 42
- 55
33
votes
2 answers
Catching SIGTERM vs catching SIGINT
In Node.js servers, is there any difference between catching SIGTERM vs catching SIGINT?
I thought processes were not supposed to be able to prevent shutdown upon a SIGINT?
process.once('SIGINT', function (code) {
console.log('SIGINT…

Alexander Mills
- 90,741
- 139
- 482
- 817
26
votes
10 answers
How to detect pending system shutdown on Linux?
I am working on an application where I need to detect a system shutdown.
However, I have not found any reliable way get a notification on this event.
I know that on shutdown, my app will receive a SIGTERM signal followed by a SIGKILL. I want to…

341008
- 9,862
- 11
- 52
- 84
21
votes
3 answers
Capture Heroku SIGTERM in Celery workers to shutdown worker gracefully
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…

jdotjdot
- 16,134
- 13
- 66
- 118
18
votes
4 answers
how can I kill a Linux process in java with SIGKILL Process.destroy() does SIGTERM
In Linux when I run the destroy function on java.lang.Process object (Which is true typed java.lang.UNIXProcess ) it sends a SIGTERM signal to process, is there a way to kill it with SIGKILL?

ekeren
- 3,408
- 3
- 35
- 55
16
votes
3 answers
Win32 API analog of sending/catching SIGTERM
Under POSIX OS there is signal API that allows to send a signal to process to shut it down
with kill and you can catch it with sigaction and do what you need;
However, Win32 is not POSIX system, so:
How can I handle shutdown events that may come,…

Artyom
- 31,019
- 21
- 127
- 215
14
votes
1 answer
How to gracefully shut down (SIGTERM) an Apollo Server instance?
The actual HTTP server instance can be killed with server.close(callback), but I'm not sure what will happen with any pending WebSocket operations (mutations or queries being run through WebSockets). Since http.Server doesn't really know anything…

Fabis
- 1,932
- 2
- 20
- 37
13
votes
11 answers
SonarQube exits with 143
I am trying to Setup SonarQube on Centos 6 VM with 6GB of RAM. The process always exits with 143.
On analysis I found that the JVM is being sent a SIGTERM signal and thus exiting. There are no core dumps and dmesg is also quite unhelpful. I also…

user1740925
- 139
- 1
- 1
- 4
11
votes
4 answers
shell script to spawn processes, terminate children on SIGTERM
I want to write a shell script that spawns several long-running processes in the background, then hangs around. Upon receiving SIGTERM, I want all the subprocesses to terminate as well.
Basically, I want a "master process".
Here's what I got so…

itsadok
- 28,822
- 30
- 126
- 171
11
votes
4 answers
Docker bash shell script does not catch SIGINT or SIGTERM
I have the following two files in a directory:
Dockerfile
FROM debian
WORKDIR /app
COPY start.sh /app/
CMD ["/app/start.sh"]
start.sh (with permissions 755 using chmod +x start.sh)
#!/bin/bash
trap "echo SIGINT; exit" SIGINT
trap "echo SIGTERM;…

thesilican
- 581
- 5
- 17