本文整理汇总了Python中cpopen.CPopen.kill方法的典型用法代码示例。如果您正苦于以下问题:Python CPopen.kill方法的具体用法?Python CPopen.kill怎么用?Python CPopen.kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cpopen.CPopen
的用法示例。
在下文中一共展示了CPopen.kill方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBrokenPipe
# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
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: testCloseFDs
# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
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: testBrokenPipeSIGPIPERestored
# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
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: testNoCloseFds
# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
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: testInheritParentFdsCloseFds
# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
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: testInheritParentFds
# 需要导入模块: from cpopen import CPopen [as 别名]
# 或者: from cpopen.CPopen import kill [as 别名]
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)