[New-bugs-announce] [issue42736] Add support for making Linux prctl(...) calls to subprocess

Gregory P. Smith report at bugs.python.org
Fri Dec 25 00:55:16 EST 2020


New submission from Gregory P. Smith <greg at krypto.org>:

Another use of `subprocess preexec_fn=` that I've come across has been to call Linux's `prctl` in the child process before the `exec`.

`_libc.prctl(_PR_SET_PDEATHSIG, value)` for example.

Adding a linux_prctl_calls= parameter listing information about which prctl call(s) to make in the child before exec would satisfy this needed.

No need to go overboard here, this is a _very_ low level syscall.  users need to know what they're doing and will likely abstract use away from actual users via a wrapper library.  i.e: Lets not attempt to reinvent the https://pythonhosted.org/python-prctl/ interface.

Proposal:

linux_prctl_calls: Sequence[tuple]

Where every tuple indicates one prctl call.  the tuple [0] contains a bool indicating if an error returned by that prctl call should be ignored or not.  the tuple[1:6] contain the five int arguments to be passed to prctl.  If the tuple is shorter than 2 elements, the remaining values are assumed 0.

At most, a namedtuple type could be created for this purpose to allow the user to use the https://man7.org/linux/man-pages/man2/prctl.2.html argument names rather than just blindly listing a tuple.

```
namedtuple('LinuxPrctlDescription',
            field_names='check_error, option, arg2, arg3, arg4, arg5',
            defaults=(0,0,0,0))
```

This existing helps https://bugs.python.org/issue38435 deprecate preexec_fn.

----------
components: Extension Modules, Library (Lib)
messages: 383723
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: Add support for making Linux prctl(...) calls to subprocess
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42736>
_______________________________________


More information about the New-bugs-announce mailing list