Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Unusual Python interpreter problem with os.fork()

Reply
Thread Tools

Unusual Python interpreter problem with os.fork()

 
 
DLitgo
Guest
Posts: n/a
 
      03-06-2009
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"])
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Unusual Python interpreter problem with os.fork() Jean-Paul Calderone Python 1 03-06-2009 07:24 PM
Python embedded interpreter: how to initialize the interpreter ? ycollet@freesurf.fr Python 3 01-03-2007 01:00 AM
Unusual Python Sighting Scott David Daniels Python 1 09-10-2005 07:06 PM
Python interpreter in Basic or a Python-2-Basic translator. Engineer Python 6 05-01-2005 10:16 PM
static program including python interpreter + dynamic python extensions Tim Fuehner Python 0 12-08-2003 01:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57