plash
[Top][All Lists]
Advanced

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

Re: [Plash] Odd popen behaviour


From: Toby Murray
Subject: Re: [Plash] Odd popen behaviour
Date: Tue, 20 Jun 2006 13:02:33 +0930
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113

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), see
/usr/lib/pyton2.4/popen2.py and also /usr/lib/python2.4/subprocess.py -- I'm not sure which is responsible but both exhibit the same behaviour which I was able to confirm is occuring using strace.

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.

It appears that os.popen2() doesn't expect that the shell you're
executing is going to want to have any other file descriptors open,
which clearly makes it problematic for plash.

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

Thomas Leonard wrote:

> This Python program behaves strangely under plash:
>
> import os
> cin, cout = os.popen2(('echo', 'hello'))
> cin.close()
> print "GOT:", `cout.read()`
> cout.close()
>
> $ /usr/bin/python t.py
> GOT: 'hello\n'
> $ pola-run --prog /usr/bin/python -B -a t.py -fw /
> GOT: ''
>
> Anyone know why?
>
>


--
Toby Murray
Advanced Computer Capabilities Group
Information Networks Division
DSTO, Australia

IMPORTANT: This e-mail remains the property of the Australian Defence
Organisation and is subject to the jurisdiction of section 70 of the
Crimes Act 1914. If you have received this e-mail in error, you are
requested to contact the sender and delete the e-mail.



--
Toby Murray
Advanced Computer Capabilities Group
Information Networks Division
DSTO, Australia

IMPORTANT: This e-mail remains the property of the Australian Defence
Organisation and is subject to the jurisdiction of section 70 of the
Crimes Act 1914. If you have received this e-mail in error, you are
requested to contact the sender and delete the e-mail.




reply via email to

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