作業系統工具¶
-
PyObject *PyOS_FSPath(PyObject *path)¶
- 回傳值:新的參照。 為 穩定 ABI 的一部分 自 3.6 版本開始.
Return the file system representation for path. If the object is a
strorbytesobject, then a new strong reference is returned. If the object implements theos.PathLikeinterface, then__fspath__()is returned as long as it is astrorbytesobject. OtherwiseTypeErroris raised andNULLis returned.在 3.6 版被加入.
-
int Py_FdIsInteractive(FILE *fp, const char *filename)¶
Return true (nonzero) if the standard I/O file fp with name filename is deemed interactive. This is the case for files for which
isatty(fileno(fp))is true. If thePyConfig.interactiveis non-zero, this function also returns true if the filename pointer isNULLor if the name is equal to one of the strings'<stdin>'or'???'.This function must not be called before Python is initialized.
-
void PyOS_BeforeFork()¶
- 為 穩定 ABI 的一部分 on platforms with fork() 自 3.7 版本開始.
Function to prepare some internal state before a process fork. This should be called before calling
fork()or any similar function that clones the current process. Only available on systems wherefork()is defined.警告
The C
fork()call should only be made from the "main" thread (of the "main" interpreter). The same is true forPyOS_BeforeFork().在 3.7 版被加入.
-
void PyOS_AfterFork_Parent()¶
- 為 穩定 ABI 的一部分 on platforms with fork() 自 3.7 版本開始.
Function to update some internal state after a process fork. This should be called from the parent process after calling
fork()or any similar function that clones the current process, regardless of whether process cloning was successful. Only available on systems wherefork()is defined.警告
The C
fork()call should only be made from the "main" thread (of the "main" interpreter). The same is true forPyOS_AfterFork_Parent().在 3.7 版被加入.
-
void PyOS_AfterFork_Child()¶
- 為 穩定 ABI 的一部分 on platforms with fork() 自 3.7 版本開始.
Function to update internal interpreter state after a process fork. This must be called from the child process after calling
fork(), or any similar function that clones the current process, if there is any chance the process will call back into the Python interpreter. Only available on systems wherefork()is defined.警告
The C
fork()call should only be made from the "main" thread (of the "main" interpreter). The same is true forPyOS_AfterFork_Child().在 3.7 版被加入.
也參考
os.register_at_fork()allows registering custom Python functions to be called byPyOS_BeforeFork(),PyOS_AfterFork_Parent()andPyOS_AfterFork_Child().
-
void PyOS_AfterFork()¶
- 為 穩定 ABI 的一部分 on platforms with fork().
Function to update some internal state after a process fork; this should be called in the new process if the Python interpreter will continue to be used. If a new executable is loaded into the new process, this function does not need to be called.
在 3.7 版之後被棄用: This function is superseded by
PyOS_AfterFork_Child().
-
int PyOS_CheckStack()¶
- 為 穩定 ABI 的一部分 on platforms with USE_STACKCHECK 自 3.7 版本開始.
Return true when the interpreter runs out of stack space. This is a reliable check, but is only available when
USE_STACKCHECKis defined (currently on certain versions of Windows using the Microsoft Visual C++ compiler).USE_STACKCHECKwill be defined automatically; you should never change the definition in your own code.
-
typedef void (*PyOS_sighandler_t)(int)¶
- 為 穩定 ABI 的一部分.
-
PyOS_sighandler_t PyOS_getsig(int i)¶
- 為 穩定 ABI 的一部分.
Return the current signal handler for signal i. This is a thin wrapper around either
sigaction()orsignal(). Do not call those functions directly!
-
PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)¶
- 為 穩定 ABI 的一部分.
Set the signal handler for signal i to be h; return the old signal handler. This is a thin wrapper around either
sigaction()orsignal(). Do not call those functions directly!
-
int PyOS_InterruptOccurred(void)¶
- 為 穩定 ABI 的一部分.
Check if a
SIGINTsignal has been received.Returns
1if aSIGINThas occurred and clears the signal flag, or0otherwise.In most cases, you should prefer
PyErr_CheckSignals()over this function.PyErr_CheckSignals()invokes the appropriate signal handlers for all pending signals, allowing Python code to handle the signal properly. This function only detectsSIGINTand does not invoke any Python signal handlers.This function is async-signal-safe and this function cannot fail. The caller must hold an attached thread state.
- wchar_t