(For the reference, since paste.debian.net links will expire in a few days:)
A minimal example to trigger the buggy behaviour is:
from subprocess import * p1 = Popen('cat', stdin=PIPE) p2 = Popen('cat', stdin=PIPE) print 'p1.communicate()' p1.communicate() print 'p2.communicate()' p2.communicate()
A simple ls in /proc shows that p2 inherits fd of the other side of p1's stdin:
$ ls -l /proc/965[45]/fd/ /proc/9654/fd/: total 0 lr-x------ 1 jwilk users 64 Aug 5 23:54 0 -> pipe:[213041] lrwx------ 1 jwilk users 64 Aug 5 23:54 1 -> /dev/pts/3 lrwx------ 1 jwilk users 64 Aug 5 23:54 2 -> /dev/pts/3
/proc/9655/fd/: total 0 lr-x------ 1 jwilk users 64 Aug 5 23:54 0 -> pipe:[213043] lrwx------ 1 jwilk users 64 Aug 5 23:54 1 -> /dev/pts/3 lrwx------ 1 jwilk users 64 Aug 5 23:54 2 -> /dev/pts/3 l-wx------ 1 jwilk users 64 Aug 5 23:54 4 -> pipe:[213041]
-- Jakub Wilk
(For the reference, since paste.debian.net links will expire in a few
days:)
A minimal example to trigger the buggy behaviour is:
from subprocess import *
p1 = Popen('cat', stdin=PIPE)
p2 = Popen('cat', stdin=PIPE)
print 'p1.communicate()'
p1.communicate()
print 'p2.communicate()'
p2.communicate()
A simple ls in /proc shows that p2 inherits fd of the other side of p1's
stdin:
$ ls -l /proc/965[45]/fd/
/proc/9654/fd/:
total 0
lr-x------ 1 jwilk users 64 Aug 5 23:54 0 -> pipe:[213041]
lrwx------ 1 jwilk users 64 Aug 5 23:54 1 -> /dev/pts/3
lrwx------ 1 jwilk users 64 Aug 5 23:54 2 -> /dev/pts/3
/proc/9655/fd/:
total 0
lr-x------ 1 jwilk users 64 Aug 5 23:54 0 -> pipe:[213043]
lrwx------ 1 jwilk users 64 Aug 5 23:54 1 -> /dev/pts/3
lrwx------ 1 jwilk users 64 Aug 5 23:54 2 -> /dev/pts/3
l-wx------ 1 jwilk users 64 Aug 5 23:54 4 -> pipe:[213041]
--
Jakub Wilk