I'm writing a Python script that'll fork a child process. The parent process should be able to write stuff like Started child at xxxxx, but the child process output should be redirected to /dev/null. How can I do that from within python?
import sys
old_stdout, old_stderr = sys.stdout, sys.stderr
sys.stdout = open('/dev/null', 'w')
sys.stderr = open('/dev/null', 'w')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With