29

I have a python script which returns the exit status of -9.

I tried to get the root of the problem with the atexit module, but it does not get called.

Any hints to help me find why and where my script terminates?

The problem is reproducible, operating system: linux 3.7.10

matanster
  • 15,072
  • 19
  • 88
  • 167
guettli
  • 25,042
  • 81
  • 346
  • 663

1 Answers1

48

The script was killed by the operating system. Negative return values are the signal number which was used to kill the process.

The script needed too much memory. I found this in syslog:

Out of memory: Kill process 26184 (python) score 439 or sacrifice child
Killed process 26184 (python) total-vm:628772kB, anon-rss:447660kB, file-rss:0kB
guettli
  • 25,042
  • 81
  • 346
  • 663
  • 2
    If you could share the exact part of the code where memory was leaked it'd make the answer better. – Shiplu Mokaddim Aug 30 '13 at 09:29
  • 3
    I am happy to know that the operating system killed the process because the memory was low. Why the script needed to much memory is an other question. – guettli Aug 30 '13 at 09:33
  • 7
    Note that negative exit status is specific to Python's [subprocess module](https://hg.python.org/cpython/file/a889c5524520/Lib/subprocess.py#l1034). Shell would [return](http://tldp.org/LDP/abs/html/exitcodes.html) `128+signum`. – Kirill Spitsyn Feb 11 '17 at 04:38
  • Last comment should probably be part of the answer if entirely accurate! – matanster Oct 01 '19 at 11:05