Wait for PID to terminate using pidfd_open() + poll(). Linux >= 5.3 only.
(self, timeout)
| 2102 | return (pid, sts) |
| 2103 | |
| 2104 | def _wait_pidfd(self, timeout): |
| 2105 | """Wait for PID to terminate using pidfd_open() + poll(). |
| 2106 | Linux >= 5.3 only. |
| 2107 | """ |
| 2108 | if not _CAN_USE_PIDFD_OPEN: |
| 2109 | return False |
| 2110 | try: |
| 2111 | pidfd = os.pidfd_open(self.pid, 0) |
| 2112 | except OSError: |
| 2113 | # May be: |
| 2114 | # - ESRCH: no such process |
| 2115 | # - EMFILE, ENFILE: too many open files (usually 1024) |
| 2116 | # - ENODEV: anonymous inode filesystem not supported |
| 2117 | # - EPERM, EACCES, ENOSYS: undocumented; may happen if |
| 2118 | # blocked by security policy like SECCOMP |
| 2119 | return False |
| 2120 | |
| 2121 | try: |
| 2122 | poller = select.poll() |
| 2123 | poller.register(pidfd, select.POLLIN) |
| 2124 | events = poller.poll(timeout * 1000) |
| 2125 | if not events: |
| 2126 | raise TimeoutExpired(self.args, timeout) |
| 2127 | return True |
| 2128 | finally: |
| 2129 | os.close(pidfd) |
| 2130 | |
| 2131 | def _wait_kqueue(self, timeout): |
| 2132 | """Wait for PID to terminate using kqueue(). macOS and BSD only.""" |
no test coverage detected