Question

I want to know whether Trap command will be use to protect a file from SIGKILL (ALT+ F4) signal or not. If it is then the following command will does that?

trap ~/Desktop/left.py SIGABRT

I'm trying to abort the all signals which trying to close left.py.

Était-ce utile?

La solution

ALT+F4 doesn't typically send a SIGKILL. If you're trying to prevent a process from being killed when its parent shell window is closed, you want something like...

nohup ~/Desktop/left.py &

...to trap the SIGHUP.

Or you can trap all signals (except SIGKILL and SIGSTOP) inside the script itself. Take a look at the Python signal module.

Autres conseils

Inside the program text of left.py you can do something like this:

trap "" INT

That is, do nothing when SIGINT is raised. You can use TERM too if you want. I'm not sure which signal exactly is raised by Alt+F4 on your platform, and you mention SIGABRT and SIGKILL as well; you cannot ignore SIGKILL.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top