Skip to content

Instantly share code, notes, and snippets.

@ajdavis
Created August 13, 2013 15:47
Show Gist options
  • Save ajdavis/6222554 to your computer and use it in GitHub Desktop.
Save ajdavis/6222554 to your computer and use it in GitHub Desktop.
Start a process and redirect its stdout and stderr to /dev/null.
try:
from subprocess import DEVNULL # Python 3.
except ImportError:
DEVNULL = open(os.devnull, 'wb')
def start_subprocess(cmd):
"""Run cmd (a list of strings) and return a Popen instance."""
return subprocess.Popen(cmd, stdout=DEVNULL, stderr=DEVNULL)
@jabbalaci
Copy link

Thanks, just what I needed.

@bandrovskiy-as
Copy link

Thank you!!!

@clamytoe
Copy link

Very helpful, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment