from __future__ import print_function
import os
import subprocess as sp
devnul = open(os.devnull, 'r+')
print("Test 1: stdout piped to parent")
p = sp.Popen(['yes'], stdout=sp.PIPE)
print("child pid: %d" % p.pid)
print("sending SIGKILL")
p.send_signal(9)
stat = '/proc/%d/stat' % p.pid
print("reading", stat)
print(open(stat).read())
p.wait()

print("=" * 80)

print("Test 2: stdout piped to /dev/null")
p = sp.Popen(['yes'], stdout=devnul)
print("child pid: %d" % p.pid)
print("killing")
p.send_signal(9)
stat = '/proc/%d/stat' % p.pid
print("reading", stat)
print(open(stat).read())
p.wait()
