Trinket Jan 31st, 2013 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import subprocess
- import signal
- import os
- #Get all proceses owned by group "download"
- proc = subprocess.Popen(["ps","-G","download"], bufsize=-1, stdout=subprocess.PIPE)
- for line in proc.stdout: #Do this for each printed line of the above command
- fields = line.split() #Split the line according to spaces
- pid = fields #The first field is the PID of the process (field 4 is the name of it)
- if int(pid) > 0: #If its a positive number
- os.kill(int(pid), signal.SIGSTOP) #Send SIGSTOP to PID
- continue #If any problem, continue with the next line
RAW Paste Data