Jerry Feldman wrote:
Format: [my id][pid][self()] function fd
[02][ 2761][3066452896] pipe(): fd=14 [02][ 2761][3066452896] pipe(): fd=18
pipe() call to establish communication with the process about to be forked().
[02][ 3024][3066452896] close(): fd=14 [02][ 3024][3066452896] close(): fd=18
forked() process closes both,
[02][ 2761][3066452896] close(): fd=18
****> [02][ 2761][3066452896] fdopen(): fd=14
We prepare to read output from forked() process.
[01][ 2761][3074980768] fopen(): fd=18 [01][ 2761][3074980768] fclose(): fd=18 [01][ 2761][3074980768] pipe(): fd=14 [01][ 2761][3074980768] pipe(): fd=18
Another thread does a pipe() call and gets 14 and 18. This should not be happening.
Why not. At the time you call pipe(), fd14 and fd18 are closed. You appear to be passing an already closed file descriptor to fdopen.
No, fd 14 is closed by the forked() process, not the local process. Proces 3024 closes fd 14, but it's process 2761 that does the fdopen(). /Per Jessen, Zürich