plash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Plash] Odd popen behaviour


From: Thomas Leonard
Subject: Re: [Plash] Odd popen behaviour
Date: Tue, 20 Jun 2006 20:48:53 +0100

On 6/20/06, Toby Murray <address@hidden> wrote:
I was able to track this down to the os.popen2() implementation (at
least in pyton 2.4 on my Fedora Core 5 box here)
[...]
You'll see in there that the child that's forked as part of the popen2()
first closes all of its file descriptors from 3 through to 1023
inclusive before doing anything much else. In so doing, it closes the
file descriptor that's used to communicate with the plash "file server".
This prevents it from executing properly from then on.
[...]
That said, the above could all be bogus, since the plash doco at
http://plash.beasts.org/environment.html specifically indicates that
close() has been modifiefd to prevent one from losing the fd used to
communicate with the plash server. If this is the case, perhaps this
code is failing because the child may not have the PLASH_COMM_FD
environment variable set. (Sorry, I'm not infront of my machine anymore
so this is just speculation).

Looks like you're right. Here's a simpler version with the same problem:

import os
fd = os.environ.get('PLASH_COMM_FD', None)
print "FD:", fd
file('/etc/passwd')
if fd is not None:
        os.close(int(fd))
        print "Closed"
        file('/etc/passwd')

This produces:

$ python t.py
FD: None

$ pola-run --prog /usr/bin/python -B -a t.py -fw /
FD: 15
Closed
sendmsg: Bad file descriptor
recvmsg: Bad file descriptor
[14326] cap-protocol: [fd 15] to-server: connection error, errno 9
(Bad file descriptor)
Traceback (most recent call last):
 File "t.py", line 8, in ?
IOError: [Errno 38] Function not implemented: '/etc/passwd'

As far as I can see, plash's new_close() function isn't being called.


--
Dr Thomas Leonard               http://rox.sourceforge.net
GPG: 9242 9807 C985 3C07 44A6  8B9A AE07 8280 59A5 3CC1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]