예제 #1
0
파일: tests.py 프로젝트: oVirt/cpopen
 def testBrokenPipe(self):
     p = CPopen(["sleep", "1"])
     try:
         p.send_signal(signal.SIGPIPE)
     finally:
         p.kill()
     p.wait()
     self.assertEqual(p.returncode, -signal.SIGKILL)
예제 #2
0
파일: tests.py 프로젝트: oVirt/cpopen
 def testCloseFDs(self):
     with open("/dev/zero") as f:
         p = CPopen(["sleep", "1"], close_fds=True)
         try:
             child_fds = set(os.listdir("/proc/%s/fd" % p.pid))
         finally:
             p.kill()
             p.wait()
         self.assertEqual(child_fds, set(["0", "1", "2"]))
예제 #3
0
파일: tests.py 프로젝트: oVirt/cpopen
 def testBrokenPipeSIGPIPERestored(self):
     if not cpopen.SUPPORTS_RESTORE_SIGPIPE:
         raise SkipTest("subprocess module does not support restore_sigpipe")
     p = CPopen(["sleep", "1"], restore_sigpipe=True)
     try:
         p.send_signal(signal.SIGPIPE)
     finally:
         p.kill()
     p.wait()
     self.assertEqual(p.returncode, -signal.SIGPIPE)
예제 #4
0
파일: tests.py 프로젝트: oVirt/cpopen
 def testNoCloseFds(self):
     with open("/dev/zero") as f:
         p = CPopen(["sleep", "1"], close_fds=False)
         try:
             child_fds = set(os.listdir("/proc/%s/fd" % p.pid))
         finally:
             p.kill()
             p.wait()
         # We cannot know which fds will be inherited in the child since the
         # test framework may open some fds.
         self.assertTrue(str(f.fileno()) in child_fds)
예제 #5
0
파일: tests.py 프로젝트: oVirt/cpopen
 def testInheritParentFdsCloseFds(self):
     # From Python docs: If close_fds is true, all file descriptors except
     # 0, 1 and 2 will be closed before the child process is executed.
     with open("/dev/zero") as f:
         p = CPopen(["sleep", "1"], stdin=None, stdout=None, stderr=None,
                    close_fds=True)
         try:
             child_fds = set(os.listdir("/proc/%s/fd" % p.pid))
         finally:
             p.kill()
             p.wait()
     self.assertEqual(child_fds, set(["0", "1", "2"]))
예제 #6
0
파일: tests.py 프로젝트: oVirt/cpopen
 def testInheritParentFds(self):
     # From Python docs: With the default settings of None, no redirection
     # will occur; the child's file handles will be inherited from the
     # parent.
     with open("/dev/zero") as f:
         p = CPopen(["sleep", "1"], stdin=None, stdout=None, stderr=None,
                    close_fds=False)
         try:
             child_fds = set(os.listdir("/proc/%s/fd" % p.pid))
         finally:
             p.kill()
             p.wait()
         expected_fds = set(["0", "1", "2", str(f.fileno())])
     self.assertEqual(child_fds, expected_fds)