pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/pull/14093/files

media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-2d31826944fd3be8.css" /> [3.8] bpo-35537: Rewrite setsid test for os.posix_spawn (GH-11721) by miss-islington · Pull Request #14093 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions Lib/test/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1639,23 +1639,35 @@ def test_setsigmask_wrong_type(self):
os.environ, setsigmask=[signal.NSIG,
signal.NSIG+1])

@unittest.skipIf(True,
"FIXME: bpo-35537: test fails is setsid is supported")
def test_start_new_session(self):
# For code coverage of calling setsid(). We don't care if we get an
# EPERM error from it depending on the test execution environment, that
# still indicates that it was called.
code = "import os; print(os.getpgid(os.getpid()))"
def test_setsid(self):
rfd, wfd = os.pipe()
self.addCleanup(os.close, rfd)
try:
self.spawn_func(sys.executable,
[sys.executable, "-c", code],
os.environ, setsid=True)
except NotImplementedError as exc:
self.skipTest("setsid is not supported: %s" % exc)
else:
parent_pgid = os.getpgid(os.getpid())
child_pgid = int(output)
self.assertNotEqual(parent_pgid, child_pgid)
os.set_inheritable(wfd, True)

code = textwrap.dedent(f"""
import os
fd = {wfd}
sid = os.getsid(0)
os.write(fd, str(sid).encode())
""")

try:
pid = self.spawn_func(sys.executable,
[sys.executable, "-c", code],
os.environ, setsid=True)
except NotImplementedError as exc:
self.skipTest(f"setsid is not supported: {exc!r}")
except PermissionError as exc:
self.skipTest(f"setsid failed with: {exc!r}")
finally:
os.close(wfd)

self.assertEqual(os.waitpid(pid, 0), (pid, 0))
output = os.read(rfd, 100)
child_sid = int(output)
parent_sid = os.getsid(os.getpid())
self.assertNotEqual(parent_sid, child_sid)

@unittest.skipUnless(hasattr(signal, 'pthread_sigmask'),
'need signal.pthread_sigmask()')
Expand Down
9 changes: 4 additions & 5 deletions Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1705,16 +1705,15 @@ def test_start_new_session(self):
# still indicates that it was called.
try:
output = subprocess.check_output(
[sys.executable, "-c",
"import os; print(os.getpgid(os.getpid()))"],
[sys.executable, "-c", "import os; print(os.getsid(0))"],
start_new_session=True)
except OSError as e:
if e.errno != errno.EPERM:
raise
else:
parent_pgid = os.getpgid(os.getpid())
child_pgid = int(output)
self.assertNotEqual(parent_pgid, child_pgid)
parent_sid = os.getsid(0)
child_sid = int(output)
self.assertNotEqual(parent_sid, child_sid)

def test_run_abort(self):
# returncode handles signal termination
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy