Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to handle os.system sigkill signal inside python?

I have a python script where I call a lengthy process from the operating system. After a long while, the process that I call gets terminated by the system by SIGKILL signal.

Is it possible to handle this from inside Python like in a try and catch situation?

What method should I use to solve this issue. It is very important that this process keeps on running as long as possible without any interruptions.

like image 786
AhMaD AbUIeSa Avatar asked Oct 20 '15 17:10

AhMaD AbUIeSa


1 Answers

There is no way to handle SIGKILL

The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.

If you're looking to handle system shutdown gracefully, you should be handling SIGTERM or a startup/shutdown script such as an upstart job or a init.d script.

like image 165
Dark Falcon Avatar answered Sep 17 '22 15:09

Dark Falcon