I'm trying to send a signal to the django development server to kill the parent and child processes.
$ python manage.py runserver
Validating models...
0 errors found
Django version 1.4.1, using settings 'myproject.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
$ ps axf
26077 pts/12 Ss 0:00 \_ -bash
4189 pts/12 S+ 0:00 | \_ python manage.py runserver
4194 pts/12 Sl+ 0:00 | \_ /myproject/.virtualenv/bin/python manage.py runserver
$ kill -s SIGINT 4189
$ ps axf
4194 pts/12 Sl 0:00 /sh/myproject/.virtualenv/bin/python manage.py runserver
My understanding is that SIGINT should emulate pressing Ctrl-C in the terminal, but notice that SIGINT terminates the parent, 4189, but not the child, 4194. Same behavior for SIGKILL, SIGTERM, SIGSTOP. Using Ctrl-C from the terminal kills both as expected.
Is there a way to terminate the parent in a way that also kills the child without knowing the child's PID?
kill -9 4189
Have a try, it should work!
Put a dash in front of the process, this should kill the process group.
kill -s SIGINT -4189
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With