Unix Programming - problems with pipe()

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2006 > problems with pipe()





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author problems with pipe()
maria

2006-04-11, 9:59 am

I have a c++ program that spawns a bunch of child processes, one at a
time. There is never more than one parent and one child at a given
time. It's also opening a pipe so the child can write to the parent.
This works for a while, and then the pipe() starts acting strangely.

The calls to pipe() are always returning success. I am printing out
the file descriptor pairs as they are created, and they are always 6 &
7, so I'm closing them properly and not running out of descriptors.

But after about 7000 iterations, the read descriptor (fd[0]) comes back
as 0, instead of 6 or some other reasonable value. pipe() is returning
0 still, as if it were succeeding, and errno isn't set to anything
relevant. Any ideas why this might be happening or how I can prevent
it?

Ralf Fassel

2006-04-11, 9:59 am

* "maria" <marialgullickson@yahoo.com>
| But after about 7000 iterations, the read descriptor (fd[0]) comes
| back as 0, instead of 6 or some other reasonable value.

Descriptor 0 is a reasonable value if stdin was closed somehow.

It would help if you supply details on
- Operating System version
- compiler version
- some example code

R'
davids@webmaster.com

2006-04-27, 7:55 am

It may help to make a library that you LD_PRELOAD (or otherwise
interpose between the program and libc) that intercepts calls to
'close'. If the file descriptor being closed is zero, it calls 'abort'.
That should give you a core dump that points right to the offending
code.

DS

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com