Using Python on a fork-less POSIX-like OS

Terry Reedy tjreedy at
Sun Jul 29 17:55:02 EDT 2018

On 7/29/2018 10:28 AM, Jan Claeys wrote:
> On Fri, 2018-07-27 at 19:13 +0200, Barath Aron wrote:
>> I intend to cross-compile Python v3.6.6 to Threos (
>>   ) operating system. Threos is supports a quite large set from
>> POSIX and C89/C99. Unfortunately, Threos lacks fork(2), but
>> provides posix_spawn(3) instead. I already made some local changes
>> in posixmodule.c to compile due to some features are detected
>> as present but actually not supported, like HAVE_FORK -- I blame
>> autotools for this :-).

Then perhaps Threos should be patched to describe itself more accurately 
or autotools patched to detect more accurately.

>> I don't know, however, whether the Python
>> shall cross-compile without issues.

We generally prefer that it does, but no longer try to officially 
support (with conditionals in the codebase) every odd-ball OS.  You or 
some Threos group may have to keep a separate patch set, to be update 
for each Python version.  If there is any such thing now, Google does 
not find it.

>> My question is that the _posixsubprocess.c can be prepared to
>> use posix_spawn(3) instead of fork(2)?

What does the doc for _posixubprocess so it does?  If it says 'create a 
subprocess by forking', then perhaps not.

>> Maybe the UNIX/Linux version
>> can also benefit from it, see:
>> team/ruby-posix-spawn
> You might want to ask this on the python-dev mailing list.

multiprocessing module uses 'spawn' rather than 'fork' on Windows and it 
has an option to use 'spawn' even on *nix.  I presume the latter refers 
to posix_spawn.  You might want to check the multiprocessing code to see 
what *it* is doing 'under the covers'.

Terry Jan Reedy

More information about the Python-list mailing list