Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to send a SIGTERM signal to a nohup process, but this signal is completely ignored, only SIGKILL works, which is considered a bad choice to terminate a shell script. Do I have any options here or do I have to stick to SIGKILL? Thanks in advance.

share|improve this question

migrated from Nov 14 '12 at 13:39

This question came from our site for professional and enthusiast programmers.

You may want to take this to – Ali Nov 13 '12 at 18:40
I'm pretty sure nohup is not supposed to trap SIGTERM, unless you happen to be using the 4.3 BSD version. Maybe the script itself is ignoring the signal? – Frédéric Hamidi Nov 13 '12 at 18:48
so sigterm is masked as well, check for external executions inside your bash script and find which one is responsible, you may find an alternative solution – arash kordi Nov 13 '12 at 18:50
If the author of the program made it ignore SIGTERM, surely he will have documented a way to stop it. Perhaps it really does want SIGKILL. Without access to information about this particular program, we can only guess. – tripleee Nov 13 '12 at 18:53
Did you try SIGQUIT (before SIGKILL)? – Basile Starynkevitch Nov 13 '12 at 19:17
up vote 2 down vote accepted

I'm sure nohup traps only SIGHUP and not SIGTERM.

If I remember correctly, bash ignores all SIGTERM and SIGQUIT signals sent to it, unless traps have been setup. Look here to findout how to setup traps in your script:

You can verify it this is the problem by first starting your script without nohup, then send a SIGTERM to it and see if it is ignored.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .