This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gregory.p.smith
Recipients gregory.p.smith
Date 2020-12-25.05:55:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1608875716.63.0.116569716148.issue42736@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-12-25 05:55:16gregory.p.smithsetrecipients: + gregory.p.smith
2020-12-25 05:55:16gregory.p.smithsetmessageid: <1608875716.63.0.116569716148.issue42736@roundup.psfhosted.org>
2020-12-25 05:55:16gregory.p.smithlinkissue42736 messages
2020-12-25 05:55:16gregory.p.smithcreate