2

Is there some guideline on how much time a linux process should maximally take to exit after receiving a SIGTERM signal?

EDIT: I'm asking because I have to decide on timeouts for blocking I/O calls.

Fran Borcic
  • 696
  • 6
  • 8
  • 2
    I've seen some taking up to 5 seconds, but I'd rather say as fast as possible. Close open connections, save setings & data, clear memory, an that's it. Other times I've seen cases where the SIGTERM has been remaped to another functionality. – Falk Feb 02 '16 at 09:24
  • @Falk: that should have been an answer – Basile Starynkevitch Feb 02 '16 at 09:27
  • I'm asking because I need to decide on timeouts for blocking i/o calls. – Fran Borcic Feb 02 '16 at 09:30
  • @FranBorcic: that should go in the question, you should edit it – Basile Starynkevitch Feb 02 '16 at 09:33
  • I'm sorry I don't have any reference about, I can't just write this as an answer. – Falk Feb 02 '16 at 09:34
  • Timeouts shouldn't matter because your I/O will be interrupted and you will get errno==EINTR. – n. m. could be an AI Feb 02 '16 at 09:39
  • In my case, it won't. It's too complex to elaborate here, but it involves multiple python threads blocked not only by system I/O, but also by threading control locks. – Fran Borcic Feb 02 '16 at 09:48
  • What kind of I/O calls do you have? If they are hdd I/O you can give it time since the hdd usualy don't just disapers. It's diferent if they are network I/O because network conections may break. – Falk Feb 02 '16 at 11:14

1 Answers1

0

There is no maximum. A process can simply ignore SIGTERM. It can be stopped, in which case it won't handle the SIGTERM until it gets a SIGCONT. It can be blocked in an uninterruptible system call. (I don't have a current example, but I certainly remember uninterruptible reads/writes when a hard mounted NFS server had failed. And if you happen to be writing your own kernel modules, well...) Finally, if the system is under heavy load, it can take much longer for the process to respond to the signal.

dan4thewin
  • 1,134
  • 7
  • 10