Skip to content

Instantly share code, notes, and snippets.

@ted-dev-42
ted-dev-42 / gist:bd19224a4b6cc79470118337cc3bdc8b
Created May 25, 2019 02:50
kill process and it's subprocesses
import subprocess
import psutil
def kill_proc_and_sub(pid):
print("kill proc and all it's subprocesses: {}".format(pid))
try:
parent_process = psutil.Process(pid)
except Exception as ex:
print("kill proc failed: " + ex.message)
return
@ted-dev-42
ted-dev-42 / gist:e120e4d0bd5af0e6c50d6a9713456789
Created June 21, 2016 05:43
java runtime exec: get stdout and stderr
import java.util.*;
import java.io.*;
class StreamGobbler extends Thread
{
InputStream is;
String type;
StreamGobbler(InputStream is, String type)
{
this.is = is;