you can check whether or not it is available using :data:`os.supports_fd`.
If it is unavailable, using it will raise a :exc:`NotImplementedError`.
+ .. audit-event:: os.exec path,args,env os.execl
+
.. availability:: Unix, Windows.
.. versionadded:: 3.3
:c:data:`POSIX_SPAWN_SETSCHEDPARAM` and :c:data:`POSIX_SPAWN_SETSCHEDULER`
flags.
+ .. audit-event:: os.posix_spawn path,argv,env os.posix_spawn
+
.. versionadded:: 3.8
.. availability:: Unix.
for the *executable* file in the list of directories specified by the
:envvar:`PATH` environment variable (in the same way as for ``execvp(3)``).
+ .. audit-event:: os.posix_spawn path,argv,env os.posix_spawnp
+
.. versionadded:: 3.8
.. availability:: See :func:`posix_spawn` documentation.
L = ['cp', 'index.html', '/dev/null']
os.spawnvpe(os.P_WAIT, 'cp', L, os.environ)
+ .. audit-event:: os.spawn mode,path,args,env os.spawnl
+
.. availability:: Unix, Windows. :func:`spawnlp`, :func:`spawnlpe`, :func:`spawnvp`
and :func:`spawnvpe` are not available on Windows. :func:`spawnle` and
:func:`spawnve` are not thread-safe on Windows; we advise you to use the
function is not resolved until this function is first called. If the function
cannot be resolved, :exc:`NotImplementedError` will be raised.
+ .. audit-event:: os.startfile path,operation os.startfile
+
.. availability:: Windows.
return NULL;
}
+ if (PySys_Audit("os.exec", "OOO", path->object ? path->object : Py_None,
+ argv, Py_None) < 0) {
+ free_string_array(argvlist, argc);
+ return NULL;
+ }
+
_Py_BEGIN_SUPPRESS_IPH
#ifdef HAVE_WEXECV
_wexecv(path->wide, argvlist);
if (!PyList_Check(argv) && !PyTuple_Check(argv)) {
PyErr_SetString(PyExc_TypeError,
"execve: argv must be a tuple or list");
- goto fail;
+ goto fail_0;
}
argc = PySequence_Size(argv);
if (argc < 1) {
if (!PyMapping_Check(env)) {
PyErr_SetString(PyExc_TypeError,
"execve: environment must be a mapping object");
- goto fail;
+ goto fail_0;
}
argvlist = parse_arglist(argv, &argc);
if (argvlist == NULL) {
- goto fail;
+ goto fail_0;
}
if (!argvlist[0][0]) {
PyErr_SetString(PyExc_ValueError,
"execve: argv first element cannot be empty");
- goto fail;
+ goto fail_0;
}
envlist = parse_envlist(env, &envc);
if (envlist == NULL)
- goto fail;
+ goto fail_0;
+
+ if (PySys_Audit("os.exec", "OOO", path->object ? path->object : Py_None,
+ argv, env) < 0) {
+ goto fail_1;
+ }
_Py_BEGIN_SUPPRESS_IPH
#ifdef HAVE_FEXECVE
/* If we get here it's definitely an error */
posix_path_error(path);
-
+ fail_1:
free_string_array(envlist, envc);
- fail:
+ fail_0:
if (argvlist)
free_string_array(argvlist, argc);
return NULL;
}
attrp = &attr;
+ if (PySys_Audit("os.posix_spawn", "OOO",
+ path->object ? path->object : Py_None, argv, env) < 0) {
+ goto exit;
+ }
+
_Py_BEGIN_SUPPRESS_IPH
#ifdef HAVE_POSIX_SPAWNP
if (use_posix_spawnp) {
mode = _P_OVERLAY;
#endif
+ if (PySys_Audit("os.spawn", "iOOO", mode,
+ path->object ? path->object : Py_None, argv,
+ Py_None) < 0) {
+ free_string_array(argvlist, argc);
+ return NULL;
+ }
+
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
#ifdef HAVE_WSPAWNV
mode = _P_OVERLAY;
#endif
+ if (PySys_Audit("os.spawn", "iOOO", mode,
+ path->object ? path->object : Py_None, argv, env) < 0) {
+ goto fail_2;
+ }
+
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
#ifdef HAVE_WSPAWNV
else
res = Py_BuildValue(_Py_PARSE_INTPTR, spawnval);
+ fail_2:
while (--envc >= 0)
PyMem_DEL(envlist[envc]);
PyMem_DEL(envlist);
"startfile not available on this platform");
}
+ if (PySys_Audit("os.startfile", "Ou",
+ filepath->object ? filepath->object : Py_None,
+ operation) < 0) {
+ return NULL;
+ }
+
Py_BEGIN_ALLOW_THREADS
rc = Py_ShellExecuteW((HWND)0, operation, filepath->wide,
NULL, NULL, SW_SHOWNORMAL);