Python os.killpg() Method
Example
Send a signal to the specified process id:
#Import os Library
import os
# Get current process group id
pgid = os.getpgid(os.getpid())
# pgid greater than 0 denotes the parent group process
if pgid :
print("\nIn parent group process")
os.killpg(pgid, 0)
print("Child stopped...")
else :
print("In Child process")
print("Process ID:", os.getpgid(os.getpid()))
Try it Yourself »
Definition and Usage
The os.killpg()
method sends a signal to the process with the specified process id.
Note: Available on UNIX platforms only.
Syntax
os.killpg(pgid, sig)
Parameter Values
Parameter | Description |
---|---|
pgid | Required. The process group id to which signal is to be sent |
sig | Required. The signal number |
Technical Details
Return Value: | None |
---|---|
Python Version: | 2.3 |