[Python-Dev] Fork on Win32 - was (test_fork1 failing...)

M.-A. Lemburg mal@lemburg.com
Fri, 28 Jul 2000 20:12:48 +0200

Trent Mick wrote:
> On Fri, Jul 28, 2000 at 12:21:08PM +0200, M . -A . Lemburg wrote:
> > >
> > >    IIRC ActiveState contributed to Perl a version of fork that works on
> > > Win32. Has anyone looked at this? Could it be grabbed for Python? This would
> > > help heal one of the more difficult platform rifts. Emulating fork for Win32
> > > looks quite difficult to me but if its already done...
> >
> > This would indeed be a *very* useful addition and help porting
> > os.fork() applications to Win32. (Ok, in the long run they would
> > have to be converted to multi-threaded apps due to the process
> > creation overhead on Win32, but for short term porting to Win32
> > this would be a Cool Thing, IMHO.)
> >
> > Can this code be grabbed from somewhere ?
> >
> It is all in ActivePerl. You can download the source code:
> http://www.activestate.com/Products/ActivePerl/Download.html

> Besides, I would guess (and I *am* guessing, I don't know this) that the Perl
> fork stuff is fairly closely tied to Perl, i.e. it may not be easy at all to
> yank it out and plug it into Python.
> However, I echo the Bill's and Guido's sentiments. Having a hacked
> emulation of fork encourages people to use it. Once someone has their
> favorite UNIX app it running on Win32 with the fake-fork they will have
> little incentive to port it properly using threads. There will then be calls
> to improve to Win32 fork implementation... and that is the wrong support
> path.

You're probably right... :-/

BTW, (pardon my ignorance) what is the most portable way to
do the equivalent of a os.system("cmd &") as native OS
API call ? [On Unix, "cmd &" starts a new process which runs
in the background and detached from the calling process.]

I've looked at .execve and .spawnve, but they both replace
the current process.

Marc-Andre Lemburg
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/