flux-framework / flux-core

core services for the Flux resource management framework
GNU Lesser General Public License v3.0
168 stars 50 forks source link

libsubprocess: duplicated stdio file descriptors are inherited by subprocesses #6415

Closed garlick closed 3 weeks ago

garlick commented 3 weeks ago

Problem: while debugging another problem, I noticed that there are two copies of stdin, stdout, and stderr file descriptors open in subprocesses.

$ sudo flux exec -r 1 sh -c "ls /proc/\$\$/fd"
0
1
2
27
30
77

We can tell the higher numbered ones are duplicates by checking the inode number

$ sudo flux exec -r 1 sh -c "grep ino: /proc/\$\$/fdinfo/*"
/proc/2210/fdinfo/0:ino:    32579
grep: /proc/2210/fdinfo/3: No such file or directory
/proc/2210/fdinfo/1:ino:    32581
/proc/2210/fdinfo/2:ino:    32583
/proc/2210/fdinfo/27:ino:   32579
/proc/2210/fdinfo/30:ino:   32581
/proc/2210/fdinfo/77:ino:   32583
1: Exit 2

(I think maybe fd 3 is the syncfd and we are racing with its removal)

I have a fix I'll post shortly.