(self)
| 2050 | signal.NSIG+1]) |
| 2051 | |
| 2052 | def test_setsid(self): |
| 2053 | rfd, wfd = os.pipe() |
| 2054 | self.addCleanup(os.close, rfd) |
| 2055 | try: |
| 2056 | os.set_inheritable(wfd, True) |
| 2057 | |
| 2058 | code = textwrap.dedent(f""" |
| 2059 | import os |
| 2060 | fd = {wfd} |
| 2061 | sid = os.getsid(0) |
| 2062 | os.write(fd, str(sid).encode()) |
| 2063 | """) |
| 2064 | |
| 2065 | try: |
| 2066 | pid = self.spawn_func(sys.executable, |
| 2067 | [sys.executable, "-c", code], |
| 2068 | os.environ, setsid=True) |
| 2069 | except NotImplementedError as exc: |
| 2070 | self.skipTest(f"setsid is not supported: {exc!r}") |
| 2071 | except PermissionError as exc: |
| 2072 | self.skipTest(f"setsid failed with: {exc!r}") |
| 2073 | finally: |
| 2074 | os.close(wfd) |
| 2075 | |
| 2076 | support.wait_process(pid, exitcode=0) |
| 2077 | |
| 2078 | output = os.read(rfd, 100) |
| 2079 | child_sid = int(output) |
| 2080 | parent_sid = os.getsid(os.getpid()) |
| 2081 | self.assertNotEqual(parent_sid, child_sid) |
| 2082 | |
| 2083 | @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'), |
| 2084 | 'need signal.pthread_sigmask()') |
nothing calls this directly
no test coverage detected