Unusual Python interpreter problem with os.fork()

Discussion in 'Python' started by DLitgo, Mar 6, 2009.

  1. DLitgo

    DLitgo Guest

    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/
    bash).

    Basically all I did was use os.fork() which caused this strange
    problem:

    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()
    >>> >>> pid

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'i' is not defined
    >>> print 'what the hell?'

    File "<stdin>", line 1
    pdpit'htth l'?
    ^
    SyntaxError: invalid syntax
    >>> exit()

    File "<stdin>", line 1
    ex)
    ^
    SyntaxError: invalid syntax
    >>> ^D



    File "<stdin>", line 1
    rn wa ehe'it(
    ^
    SyntaxError: invalid syntax
    >>>

    KeyboardInterrupt
    >>>
    >>> exit()

    Macintosh:~ $

    Sorry for any formatting issues with the above code/output, I don't
    post on these mailing lists often and I usually just do it through
    groups.google.com in my browser.

    But as you can see something strange happens and things just get
    garbled and unusual. I restarted bash to see if that was the issue (it
    isn't) and I've also restarted my computer since I noticed this
    happening (earlier today) and nothing different happens when I import
    and use os.fork().

    I did however enter these simple lines into an empty file and ran it
    from bash which ended up going just fine:

    #file: test.py
    import os
    pid = os.fork()
    if pid == 0: os.execvp("ls", ["ls", "-l"])
     
    DLitgo, Mar 6, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William A. Sempf

    Unusual performance problem.

    William A. Sempf, Aug 27, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    382
    William A. Sempf
    Aug 27, 2003
  2. Scott David Daniels

    Unusual Python Sighting

    Scott David Daniels, Sep 10, 2005, in forum: Python
    Replies:
    1
    Views:
    287
  3. Replies:
    3
    Views:
    788
    Ziga Seilnacht
    Jan 3, 2007
  4. Eric Snow

    os.fork and pty.fork

    Eric Snow, Jan 8, 2009, in forum: Python
    Replies:
    0
    Views:
    603
    Eric Snow
    Jan 8, 2009
  5. Jean-Paul Calderone
    Replies:
    1
    Views:
    357
    DLitgo
    Mar 6, 2009
Loading...

Share This Page