[ python-Bugs-1574310 ] os.popen with os.close gives error message

SourceForge.net noreply at sourceforge.net
Tue Oct 10 09:45:09 CEST 2006


Bugs item #1574310, was opened at 2006-10-10 09:45
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1574310&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: dtrosset (dtrosset)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.popen with os.close gives error message

Initial Comment:
Given the following code:

  import os
  child_stdin = os.popen("cat -", "w")
  old_stdout = os.dup(1)
  os.close(child_stdin.fileno())
  print "foo"
  os.dup2(old_stdout, 1)
  os.close(old_stdout)


I got these different results depending on the version
of python I am using. 


$ python2.4 -V 
Python 2.4.4c0
$ python2.4 test.py 
foo
close failed: [Errno 9] Bad file descriptor

$ python2.3 -V 
Python 2.3.5
$ python2.3 test/new/test.py 
foo

My .02$ guess is that underlying file descriptor of
child_stdin being closed, when trying to delete this
object, it tries again to close it.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1574310&group_id=5470


More information about the Python-bugs-list mailing list