Unusual Python interpreter problem with os.fork()
ssj4_dave at hotmail.com
Fri Mar 6 20:24:29 CET 2009
On Mar 6, 7:20 am, Jean-Paul Calderone <exar... at divmod.com> wrote:
> On Fri, 6 Mar 2009 05:00:03 -0800 (PST), DLitgo <ssj4_d... at hotmail.com> wrote:
> >Hello everyone,
> >I have a curious problem which I'm wondering if anyone here can shed
> >some light on. I'm basically just following along with a guide which
> >is going through some of the os module, and I'm running some examples
> >in the python interpreter on mac os x (accessed through terminal/
> >Basically all I did was use os.fork() which caused this strange
> >Macintosh:~ $ python
> >Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
> >[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
> >Type "help", "copyright", "credits" or "license" for more information.
> >>>> import os
> >>>> pid = os.fork()
> As soon as this returns, you have two CPython processes reading from stdin
> and writing to stdout. They fight over your input and their output gets
> interleaved in non-deterministic ways. Basically, you probably don't ever
> want to do this.
Okay cool, I guess the example wasn't meant to be run in the
interpreter then :) Thanks for the reply.
More information about the Python-list