mirror of
https://github.com/python/cpython
synced 2024-09-16 00:07:33 +00:00
gh-95174: Handle missing waitpid and gethostbyname in WASI (GH-95181)
This commit is contained in:
parent
5c7f3bcdaf
commit
8184f0fce3
|
@ -102,8 +102,19 @@
|
||||||
else:
|
else:
|
||||||
if _can_fork_exec:
|
if _can_fork_exec:
|
||||||
from _posixsubprocess import fork_exec as _fork_exec
|
from _posixsubprocess import fork_exec as _fork_exec
|
||||||
|
# used in methods that are called by __del__
|
||||||
|
_waitpid = os.waitpid
|
||||||
|
_waitstatus_to_exitcode = os.waitstatus_to_exitcode
|
||||||
|
_WIFSTOPPED = os.WIFSTOPPED
|
||||||
|
_WSTOPSIG = os.WSTOPSIG
|
||||||
|
_WNOHANG = os.WNOHANG
|
||||||
else:
|
else:
|
||||||
_fork_exec = None
|
_fork_exec = None
|
||||||
|
_waitpid = None
|
||||||
|
_waitstatus_to_exitcode = None
|
||||||
|
_WIFSTOPPED = None
|
||||||
|
_WSTOPSIG = None
|
||||||
|
_WNOHANG = None
|
||||||
import select
|
import select
|
||||||
import selectors
|
import selectors
|
||||||
|
|
||||||
|
@ -1890,19 +1901,19 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
|
||||||
|
|
||||||
|
|
||||||
def _handle_exitstatus(self, sts,
|
def _handle_exitstatus(self, sts,
|
||||||
waitstatus_to_exitcode=os.waitstatus_to_exitcode,
|
_waitstatus_to_exitcode=_waitstatus_to_exitcode,
|
||||||
_WIFSTOPPED=os.WIFSTOPPED,
|
_WIFSTOPPED=_WIFSTOPPED,
|
||||||
_WSTOPSIG=os.WSTOPSIG):
|
_WSTOPSIG=_WSTOPSIG):
|
||||||
"""All callers to this function MUST hold self._waitpid_lock."""
|
"""All callers to this function MUST hold self._waitpid_lock."""
|
||||||
# This method is called (indirectly) by __del__, so it cannot
|
# This method is called (indirectly) by __del__, so it cannot
|
||||||
# refer to anything outside of its local scope.
|
# refer to anything outside of its local scope.
|
||||||
if _WIFSTOPPED(sts):
|
if _WIFSTOPPED(sts):
|
||||||
self.returncode = -_WSTOPSIG(sts)
|
self.returncode = -_WSTOPSIG(sts)
|
||||||
else:
|
else:
|
||||||
self.returncode = waitstatus_to_exitcode(sts)
|
self.returncode = _waitstatus_to_exitcode(sts)
|
||||||
|
|
||||||
def _internal_poll(self, _deadstate=None, _waitpid=os.waitpid,
|
def _internal_poll(self, _deadstate=None, _waitpid=_waitpid,
|
||||||
_WNOHANG=os.WNOHANG, _ECHILD=errno.ECHILD):
|
_WNOHANG=_WNOHANG, _ECHILD=errno.ECHILD):
|
||||||
"""Check if child process has terminated. Returns returncode
|
"""Check if child process has terminated. Returns returncode
|
||||||
attribute.
|
attribute.
|
||||||
|
|
||||||
|
|
|
@ -524,6 +524,8 @@ def _ip_getnode():
|
||||||
def _arp_getnode():
|
def _arp_getnode():
|
||||||
"""Get the hardware address on Unix by running arp."""
|
"""Get the hardware address on Unix by running arp."""
|
||||||
import os, socket
|
import os, socket
|
||||||
|
if not hasattr(socket, "gethostbyname"):
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
ip_addr = socket.gethostbyname(socket.gethostname())
|
ip_addr = socket.gethostbyname(socket.gethostname())
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|
Loading…
Reference in a new issue