On this page
os.kill
Prev: os.getppid | Up: os | Next: os.link
Rel: os.abort, os.access, os.chdir, os.chmod
Ref: docs.python.org — os.kill
Tags: #public #python3 #stdlib #os
Import
import os
from os import kill
Signature & Overview
os.kill(pid, signal, /)
Kill a process with a signal.
Usage
import os
# Signal 0 checks whether a process exists and can be signaled without terminating it
os.kill(os.getpid(), 0)
Gotchas
- Signal
0is a liveness check on Unix: RaisesProcessLookupErrorif the PID does not exist orPermissionErrorif owned by another user. - Prefer
proc.terminate()/proc.kill()forsubprocess.Popenchildren.
REPL Inspect
from os import kill
help(kill)
Linked from
Related notes
- tuts/python3/stdlib_module/os/getppid Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/link Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/os/abort Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/access Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chdir Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chmod Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chown shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/close shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/cpu_count shared tags: #os, #stdlib