[issue1187] pipe fd handling issues in subprocess.py on POSIX

2007-09-21 Thread Andrew Nissen

New submission from Andrew Nissen:

Revision 53293 appears to have missed some of the logic inherent in the
previous code.  There also appears to be problems with the way that the
dup2 calls are made that can result in a behavior different then
intended under a number of circumstances.

fix_fileno.py demonstrates the improper behavior

--
components: Library (Lib)
files: fix_fileno.py
messages: 56079
nosy: anissen
severity: minor
status: open
title: pipe fd handling issues in subprocess.py on POSIX
type: behavior
versions: Python 2.4

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1187>
__import os
import subprocess

STDIN		= '/tmp/stdin.test'
STDOUT		= '/tmp/stdout.test'
STDERR		= '/tmp/stderr.test'

os.close(0)
os.close(1)
os.close(2)

stdin  = open(STDIN,  'w')
stdin.close()

stdout = open(STDOUT, 'w')
stderr = open(STDERR, 'w')
stdin  = open(STDIN,  'r')

CALL_CMD	= ['/bin/cat', '/etc/rc.local']
CALL_ARGS	= { 'stdin'	: stdin,
		'stdout'	: stdout,
		'stderr'	: stderr,
		'close_fds'	: True,
		  }

subprocess.call(CALL_CMD, **CALL_ARGS)

stdin.close()
stdout.close()
stderr.close()
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1187] pipe fd handling issues in subprocess.py on POSIX

2007-09-21 Thread Andrew Nissen

Andrew Nissen added the comment:

This patch (subprocess.fix_fileno.udiff) made against subprocess.py
(Revision 55604)appears to give the desired behavior

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1187>
__

subprocess.fix_fileno.udiff
Description: Binary data
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1187] pipe fd handling issues in subprocess.py on POSIX

2008-05-13 Thread Andrew Nissen

Andrew Nissen <[EMAIL PROTECTED]> added the comment:

In reference to Dustin's entry: That's the point; the expected behavior
is that subprocess should write data to the named files, without the
fix, it doesn't.  With the subprocess module as it stands, there are a
number of cases that will not behave as the user expects.  There were
two issues that were being addressed:

1) If a user passes in a file descriptor that is in the range 0-2, the
dup2 calls end up closing the file being passed in.

2) The other issue is the close code could end up closing file
descriptors it really shouldn't.  For example if p2cread == 1, the code
ends up closing the fd even though it really probably shouldn't.  On a
side note, I should have used a list for dup_fds instead of a dictionary.

It's been a while and I've not spent a huge amount of time getting back
up to speed; if there are any questions let me know and I'll spend some
more time on this.

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1187>
__
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com