* On VxWorks, os.popen, os.fork, os.execv and os.spawn*p* are not supported.
+* On WebAssembly platforms ``wasm32-emscripten`` and ``wasm32-wasi``, large
+ parts of the :mod:`os` module are not available or behave differently. API
+ related to processes (e.g. :func:`~os.fork`, :func:`~os.execve`), signals
+ (e.g. :func:`~os.kill`, :func:`~os.wait`), and resources
+ (e.g. :func:`~os.nice`) are not available. Others like :func:`~os.getuid`
+ and :func:`~os.getpid` are emulated or stubs.
+
+
.. note::
All functions in this module raise :exc:`OSError` (or subclasses thereof) in
Return the filename corresponding to the controlling terminal of the process.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: environ
Return the effective group id of the current process. This corresponds to the
"set id" bit on the file being executed in the current process.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: geteuid()
Return the current process's effective user id.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: getgid()
.. availability:: Unix.
+ The function is a stub on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. function:: getgrouplist(user, group)
field from the password record for *user*, because that group ID will
otherwise be potentially omitted.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
Return list of supplemental group ids associated with the current process.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. note::
falls back to ``pwd.getpwuid(os.getuid())[0]`` to get the login name of the
current real user id.
- .. availability:: Unix, Windows.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
.. function:: getpgid(pid)
Return the process group id of the process with process id *pid*. If *pid* is 0,
the process group id of the current process is returned.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: getpgrp()
Return the id of the current process group.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: getpid()
Return the current process id.
+ The function is a stub on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
.. function:: getppid()
the id returned is the one of the init process (1), on Windows it is still
the same id, which may be already reused by another process.
- .. availability:: Unix, Windows.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
.. versionchanged:: 3.2
Added support for Windows.
(respectively) the calling process, the process group of the calling process,
or the real user ID of the calling process.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
Parameters for the :func:`getpriority` and :func:`setpriority` functions.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
Return a tuple (ruid, euid, suid) denoting the current process's
real, effective, and saved user ids.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.2
Return a tuple (rgid, egid, sgid) denoting the current process's
real, effective, and saved group ids.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.2
.. availability:: Unix.
+ The function is a stub on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. function:: initgroups(username, gid)
the groups of which the specified username is a member, plus the specified
group id.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.2
Set the current process's effective group id.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: seteuid(euid)
Set the current process's effective user id.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: setgid(gid)
Set the current process' group id.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: setgroups(groups)
*groups*. *groups* must be a sequence, and each element must be an integer
identifying a group. This operation is typically available only to the superuser.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. note:: On macOS, the length of *groups* may not exceed the
system-defined maximum number of effective group ids, typically 16.
Call the system call :c:func:`setpgrp` or ``setpgrp(0, 0)`` depending on
which version is implemented (if any). See the Unix manual for the semantics.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: setpgid(pid, pgrp)
process with id *pid* to the process group with id *pgrp*. See the Unix manual
for the semantics.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: setpriority(which, who, priority)
*priority* is a value in the range -20 to 19. The default priority is 0;
lower priorities cause more favorable scheduling.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
Set the current process's real and effective group ids.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: setresgid(rgid, egid, sgid)
Set the current process's real, effective, and saved group ids.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.2
Set the current process's real, effective, and saved user ids.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.2
Set the current process's real and effective user ids.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: getsid(pid)
Call the system call :c:func:`getsid`. See the Unix manual for the semantics.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: setsid()
Call the system call :c:func:`setsid`. See the Unix manual for the semantics.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: setuid(uid)
Set the current process's user id.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. placed in this section since it relates to errno.... a little weak
Set the current numeric umask and return the previous umask.
+ The function is a stub on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. function:: uname()
2: stderr), the new file descriptor is :ref:`inheritable
<fd_inheritance>`.
+ .. availability:: not WASI.
+
.. versionchanged:: 3.4
The new file descriptor is now non-inheritable.
<fd_inheritance>` by default or non-inheritable if *inheritable*
is ``False``.
+ .. availability:: not WASI.
+
.. versionchanged:: 3.4
Add the optional *inheritable* parameter.
.. availability:: Unix.
+ The function is limited on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. function:: fchown(fd, uid, gid)
.. availability:: Unix.
+ The function is limited on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. function:: fdatasync(fd)
.. availability:: Unix.
+ The function is limited on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. versionadded:: 3.5
Make the calling process a session leader; make the tty the controlling tty,
the stdin, the stdout, and the stderr of the calling process; close fd.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.11
descriptors are :ref:`non-inheritable <fd_inheritance>`. For a (slightly) more
portable approach, use the :mod:`pty` module.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionchanged:: 3.4
The new file descriptors are now non-inheritable.
Return a pair of file descriptors ``(r, w)`` usable for reading and writing,
respectively.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
Ensures that enough disk space is allocated for the file specified by *fd*
starting from *offset* and continuing for *len* bytes.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten.
.. versionadded:: 3.3
Cross-platform applications should not use *headers*, *trailers* and *flags*
arguments.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. note::
.. availability:: Unix.
+ The function is limited on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. versionadded:: 3.5
Parameters to the :func:`sendfile` function, if the implementation supports
them.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
Parameter to the :func:`sendfile` function, if the implementation supports
it. The data won't be cached in the virtual memory and will be freed afterwards.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.11
Return the process group associated with the terminal given by *fd* (an open
file descriptor as returned by :func:`os.open`).
- .. availability:: Unix.
+ .. availability:: Unix, not WASI.
.. function:: tcsetpgrp(fd, pg)
Set the process group associated with the terminal given by *fd* (an open file
descriptor as returned by :func:`os.open`) to *pg*.
- .. availability:: Unix.
+ .. availability:: Unix, not WASI.
.. function:: ttyname(fd)
streams are closed, and inheritable handles are only inherited if the
*close_fds* parameter is ``False``.
+On WebAssembly platforms ``wasm32-emscripten`` and ``wasm32-wasi``, the file
+descriptor cannot be modified.
+
.. function:: get_inheritable(fd)
Get the "inheritable" flag of the specified file descriptor (a boolean).
.. audit-event:: os.chflags path,flags os.chflags
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
The *follow_symlinks* argument.
read-only flag with it (via the ``stat.S_IWRITE`` and ``stat.S_IREAD``
constants or a corresponding integer value). All other bits are ignored.
+ The function is limited on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. audit-event:: os.chmod path,mode,dir_fd os.chmod
.. versionadded:: 3.3
.. availability:: Unix.
+ The function is limited on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. versionadded:: 3.3
Added support for specifying *path* as an open file descriptor,
and the *dir_fd* and *follow_symlinks* arguments.
Change the root directory of the current process to *path*.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.
.. audit-event:: os.chflags path,flags os.lchflags
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.
FIFO for reading, and the client opens it for writing. Note that :func:`mkfifo`
doesn't open the FIFO --- it just creates the rendezvous point.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
The *dir_fd* argument.
This function can also support :ref:`paths relative to directory descriptors
<dir_fd>`.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
The *dir_fd* argument.
.. availability:: Unix, Windows.
+ The function is limited on Emscripten and WASI, see
+ :ref:`wasm-availability` for more information.
+
.. versionchanged:: 3.2
Added support for Windows 6.0 (Vista) symbolic links.
.. audit-event:: os.exec path,args,env os.execl
- .. availability:: Unix, Windows.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
.. versionadded:: 3.3
Added support for specifying *path* as an open file descriptor
Exit code that means the command was used incorrectly, such as when the wrong
number of arguments are given.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_DATAERR
Exit code that means the input data was incorrect.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_NOINPUT
Exit code that means an input file did not exist or was not readable.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_NOUSER
Exit code that means a specified user did not exist.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_NOHOST
Exit code that means a specified host did not exist.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_UNAVAILABLE
Exit code that means that a required service is unavailable.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_SOFTWARE
Exit code that means an internal software error was detected.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_OSERR
Exit code that means an operating system error was detected, such as the
inability to fork or create a pipe.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_OSFILE
Exit code that means some system file did not exist, could not be opened, or had
some other kind of error.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_CANTCREAT
Exit code that means a user specified output file could not be created.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_IOERR
Exit code that means that an error occurred while doing I/O on some file.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_TEMPFAIL
that may not really be an error, such as a network connection that couldn't be
made during a retryable operation.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_PROTOCOL
Exit code that means that a protocol exchange was illegal, invalid, or not
understood.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_NOPERM
Exit code that means that there were insufficient permissions to perform the
operation (but not intended for file system problems).
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_CONFIG
Exit code that means that some kind of configuration error occurred.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: EX_NOTFOUND
Exit code that means something like "an entry was not found".
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: fork()
See :mod:`ssl` for applications that use the SSL module with fork().
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: forkpty()
Calling ``forkpty()`` in a subinterpreter is no longer supported
(:exc:`RuntimeError` is raised).
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: kill(pid, sig)
.. audit-event:: os.kill pid,sig os.kill
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
+
.. versionadded:: 3.2
Windows support.
.. audit-event:: os.killpg pgid,sig os.killpg
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: nice(increment)
Add *increment* to the process's "niceness". Return the new niceness.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: pidfd_open(pid, flags=0)
Lock program segments into memory. The value of *op* (defined in
``<sys/lock.h>``) determines which segments are locked.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: popen(cmd, mode='r', buffering=-1)
documentation for more powerful ways to manage and communicate with
subprocesses.
+ .. availability:: not Emscripten, not WASI.
+
.. note::
The :ref:`Python UTF-8 Mode <utf8-mode>` affects encodings used
for *cmd* and pipe contents.
.. versionadded:: 3.8
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: posix_spawnp(path, argv, env, *, file_actions=None, \
setpgroup=None, resetids=False, setsid=False, setsigmask=(), \
.. versionadded:: 3.8
- .. availability:: POSIX
+ .. availability:: POSIX, not Emscripten, not WASI.
See :func:`posix_spawn` documentation.
There is no way to unregister a function.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.7
.. audit-event:: os.spawn mode,path,args,env os.spawnl
- .. availability:: Unix, Windows.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
:func:`spawnlp`, :func:`spawnlpe`, :func:`spawnvp`
and :func:`spawnvpe` are not available on Windows. :func:`spawnle` and
.. audit-event:: os.system command os.system
- .. availability:: Unix, Windows.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
.. function:: times()
:func:`waitstatus_to_exitcode` can be used to convert the exit status into an
exit code.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. seealso::
:attr:`si_code` or ``None`` if :data:`WNOHANG` is specified and there are no
children in a waitable state.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
These are the possible values for *idtype* in :func:`waitid`. They affect
how *id* is interpreted.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
Flags that can be used in *options* in :func:`waitid` that specify what
child signal to wait for.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
These are the possible values for :attr:`si_code` in the result returned by
:func:`waitid`.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. versionadded:: 3.3
:func:`waitstatus_to_exitcode` can be used to convert the exit status into an
exit code.
+ .. availability:: Unix, not Emscripten, not WASI.
+
.. versionchanged:: 3.5
If the system call is interrupted and the signal handler does not raise an
exception, the function now retries the system call instead of raising an
:func:`waitstatus_to_exitcode` can be used to convert the exit status into an
exitcode.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: wait4(pid, options)
:func:`waitstatus_to_exitcode` can be used to convert the exit status into an
exitcode.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: waitstatus_to_exitcode(status)
:func:`WIFEXITED`, :func:`WEXITSTATUS`, :func:`WIFSIGNALED`,
:func:`WTERMSIG`, :func:`WIFSTOPPED`, :func:`WSTOPSIG` functions.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
+
.. versionadded:: 3.9
The option for :func:`waitpid` to return immediately if no child process status
is available immediately. The function returns ``(0, 0)`` in this case.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. data:: WCONTINUED
This option causes child processes to be reported if they have been continued
from a job control stop since their status was last reported.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
Some Unix systems.
This option causes child processes to be reported if they have been stopped but
their current state has not been reported since they were stopped.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
The following functions take a process status code as returned by
This function should be employed only if :func:`WIFSIGNALED` is true.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: WIFCONTINUED(status)
See :data:`WCONTINUED` option.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: WIFSTOPPED(status)
done using :data:`WUNTRACED` option or when the process is being traced (see
:manpage:`ptrace(2)`).
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: WIFSIGNALED(status)
Return ``True`` if the process was terminated by a signal, otherwise return
``False``.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: WIFEXITED(status)
by calling ``exit()`` or ``_exit()``, or by returning from ``main()``;
otherwise return ``False``.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: WEXITSTATUS(status)
This function should be employed only if :func:`WIFEXITED` is true.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: WSTOPSIG(status)
This function should be employed only if :func:`WIFSTOPPED` is true.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
.. function:: WTERMSIG(status)
This function should be employed only if :func:`WIFSIGNALED` is true.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
Interface to the scheduler
Some behavior may be platform dependent, since calls are made to the operating
system socket APIs.
+
+.. include:: ../includes/wasm-notavail.rst
+
.. index:: object: socket
The Python interface is a straightforward transliteration of the Unix system
.. audit-event:: socket.gethostbyname hostname socket.gethostbyname
+ .. availability:: not WASI.
+
.. function:: gethostbyname_ex(hostname)
.. audit-event:: socket.gethostbyname hostname socket.gethostbyname_ex
+ .. availability:: not WASI.
+
.. function:: gethostname()
Note: :func:`gethostname` doesn't always return the fully qualified domain
name; use :func:`getfqdn` for that.
+ .. availability:: not WASI.
+
.. function:: gethostbyaddr(ip_address)
.. audit-event:: socket.gethostbyaddr ip_address socket.gethostbyaddr
+ .. availability:: not WASI.
+
.. function:: getnameinfo(sockaddr, flags)
.. audit-event:: socket.getnameinfo sockaddr socket.getnameinfo
+ .. availability:: not WASI.
+
+
.. function:: getprotobyname(protocolname)
Translate an internet protocol name (for example, ``'icmp'``) to a constant
(:const:`SOCK_RAW`); for the normal socket modes, the correct protocol is chosen
automatically if the protocol is omitted or zero.
+ .. availability:: not WASI.
+
.. function:: getservbyname(servicename[, protocolname])
.. audit-event:: socket.getservbyname servicename,protocolname socket.getservbyname
+ .. availability:: not WASI.
+
.. function:: getservbyport(port[, protocolname])
.. audit-event:: socket.getservbyport port,protocolname socket.getservbyport
+ .. availability:: not WASI.
+
.. function:: ntohl(x)
buffer. Raises :exc:`OverflowError` if *length* is outside the
permissible range of values.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
Most Unix platforms.
amount of ancillary data that can be received, since additional
data may be able to fit into the padding area.
- .. availability:: Unix.
+ .. availability:: Unix, not Emscripten, not WASI.
most Unix platforms.
(index int, name string) tuples.
:exc:`OSError` if the system call fails.
- .. availability:: Unix, Windows.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
.. versionadded:: 3.3
interface name.
:exc:`OSError` if no interface with the given name exists.
- .. availability:: Unix, Windows.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
.. versionadded:: 3.3
interface index number.
:exc:`OSError` if no interface with the given index exists.
- .. availability:: Unix, Windows.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
.. versionadded:: 3.3
The *fds* parameter is a sequence of file descriptors.
Consult :meth:`sendmsg` for the documentation of these parameters.
- .. availability:: Unix.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
Unix platforms supporting :meth:`~socket.sendmsg`
and :const:`SCM_RIGHTS` mechanism.
Return ``(msg, list(fds), flags, addr)``.
Consult :meth:`recvmsg` for the documentation of these parameters.
- .. availability:: Unix.
+ .. availability:: Unix, Windows, not Emscripten, not WASI.
Unix platforms supporting :meth:`~socket.sendmsg`
and :const:`SCM_RIGHTS` mechanism.
.. audit-event:: socket.bind self,address socket.socket.bind
+ .. availability:: not WASI.
+
+
.. method:: socket.close()
Mark the socket closed. The underlying system resource (e.g. a file
signal, the signal handler doesn't raise an exception and the socket is
blocking or has a timeout (see the :pep:`475` for the rationale).
+ .. availability:: not WASI.
+
.. method:: socket.connect_ex(address)
.. audit-event:: socket.connect self,address socket.socket.connect_ex
+ .. availability:: not WASI.
+
.. method:: socket.detach()
Put the socket object into closed state without actually closing the
.. versionchanged:: 3.4
The socket is now non-inheritable.
+ .. availability:: not WASI.
+
.. method:: socket.fileno()
contents of the buffer (see the optional built-in module :mod:`struct` for a way
to decode C structures encoded as byte strings).
+ .. availability:: not WASI.
+
.. method:: socket.getblocking()
unaccepted connections that the system will allow before refusing new
connections. If not specified, a default reasonable value is chosen.
+ .. availability:: not WASI.
+
.. versionchanged:: 3.5
The *backlog* parameter is now optional.
+
.. method:: socket.makefile(mode='r', buffering=None, *, encoding=None, \
errors=None, newline=None)
def send_fds(sock, msg, fds):
return sock.sendmsg([msg], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", fds))])
- .. availability:: Unix.
+ .. availability:: Unix, not WASI.
Most Unix platforms.
*optlen* argument is required. It's equivalent to call :c:func:`setsockopt` C
function with ``optval=NULL`` and ``optlen=optlen``.
-
.. versionchanged:: 3.5
Writable :term:`bytes-like object` is now accepted.
.. versionchanged:: 3.6
setsockopt(level, optname, None, optlen: int) form added.
+ .. availability:: not WASI.
+
.. method:: socket.shutdown(how)
are disallowed. If *how* is :const:`SHUT_RDWR`, further sends and receives are
disallowed.
+ .. availability:: not WASI.
+
.. method:: socket.share(process_id)