[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-31 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
assignee:  -> gregory.p.smith
resolution:  -> fixed
stage: patch review -> commit review
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-31 Thread miss-islington


miss-islington  added the comment:


New changeset 9ed179b07df6ce7432f972f5d069a7c8dee56e79 by Miss Islington (bot) 
in branch '3.10':
bpo-47151: Fallback to fork when vfork fails in subprocess. (GH-32186)
https://github.com/python/cpython/commit/9ed179b07df6ce7432f972f5d069a7c8dee56e79


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-31 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +30295
pull_request: https://github.com/python/cpython/pull/32219

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-31 Thread Gregory P. Smith


Gregory P. Smith  added the comment:


New changeset 4a08c4c469d36f99d3a5e0f17ad82ab35dcf2835 by Gregory P. Smith in 
branch 'main':
bpo-47151: Fallback to fork when vfork fails in subprocess. (GH-32186)
https://github.com/python/cpython/commit/4a08c4c469d36f99d3a5e0f17ad82ab35dcf2835


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-31 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Thanks. I had wondered if this was really a pid=1 restriction or not, but I 
could definitely imagine kernel scenarios where vfork is simply forbidden 
regardless. There are a variety of policy mechanisms in kernels, mainline Linux 
or not, that _could_ do that kind of thing.

As much as I'd like to expose that the fallback happened, emitting to stderr 
isn't friendly and using warnings from this code is complicated so I'm inclined 
to keep the silent fallback on failure simple as is until someone can 
demonstrate of it causing a practical problem.

Outside of unusual configurations, if this were ever happening when it is not 
expected, people observing low subprocess performance could strace and witness 
the vfork syscall failure.

I'll merge once our CI is happy.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-31 Thread Марк Коренберг

Марк Коренберг  added the comment:

Well.
1. We use Python as PID 1. In PID namespace.
2. Further investigation gave information that vfork()+pid=1 actually WORKS. 
The problem is connected with another weird thing in kernel (undocumented 
unshare() flags).
3. The logic to try fork() after vfork() has failed is NICE. Please merge. I 
would also write a message to stderr in case vfork() failed.

P.S. Program may or may not be static in order to work as PID=1.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-30 Thread STINNER Victor


STINNER Victor  added the comment:

> Any possibility that you can test the attached PR as pid 1?

Python should be built as a static binary and can be used as the init process 
on the kernel command line, no? I'm not sure that "static binary" is a 
requirement, since I'm commonly using init=/usr/bin/bash to fix a broken Linux, 
and on my Fedora, this program is "dynamically linked".

Who uses Python as pid 1? I'm now curious :-)

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-29 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

Any possibility that you can test the attached PR as pid 1?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-29 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
keywords: +patch
pull_requests: +30263
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/32186

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47151] subprocess fails when used as init, vfork() returns EINVAL if PID=1

2022-03-29 Thread Gregory P. Smith


Change by Gregory P. Smith :


--
components: +Extension Modules -Library (Lib)
stage:  -> needs patch
title: vfork() returns EINVAL if PID=1 -> subprocess fails when used as init, 
vfork() returns EINVAL if PID=1
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com