execv giving a Fatal Error (11)

Steve Holden sholden at holdenweb.com
Fri Feb 22 13:53:34 CET 2002


"Rajarshi Guha" <rxg218 at psu.edu> wrote in message
news:a541uu$l0e at r02n01.cac.psu.edu...
> Hi,
>   I have a small python script which uses PyGTK. In one of the call backs
> I do:
>
> os.execv('/usr/bin/emacs',[])
>
> But as a result I get:
>
> Fatal error (11).Segmentation fault
>
> This occurs even when I run a script that contains the os.exev(...) as the
> only command.
>
> Does anybody know why this happens? Is there any other way I can implement
> this?
>
Should that be

    os.execv('/usr/bin/emacs', ['emacs'])

perhaps. Long time since I used exec, but I seem to remember it needs a
first argument in args to stand for the program name. Indeed, in cygwin
under 2.2 I get:

 >>> os.execv("/usr/bin/ls", [])
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: execv() arg 2 must not be empty

This is certainly more helpful than a segfault!

>>> os.execv("/usr/bin/ls", ['ls'])
BookProject  lib     mydatabase.fs       nonweb   sketch2.jpg  tm1.py
PyNet        mounts  mydatabase.fs.lock  rhubarb  test.cpp     tm1.pyc
bin          msqd    mydatabase.fs.tmp   share    tf           wiki

regards
 Steve
--
Consulting, training, speaking: http://www.holdenweb.com/
Author, Python Web Programming: http://pydish.holdenweb.com/pwp/

"This is Python.  We don't care much about theory, except where it
intersects with useful practice."  Aahz Maruch on c.l.py







More information about the Python-list mailing list