how to close a stalled file descriptor?



I'm having trouble closing a file descriptor on a stalled named pipe.
To unblock myself if the write takes too long because the pipe is full
and there is no reader on the other end of the pipe, I put in place
a signal handler. But if the signal handler is invoked and I regain
control, on any subsequent attempt to close the file descriptor,
it stalls again! How do I force the file descriptor to close so I
don't have an infinite buildup of file descriptors in my process,
if I want to continue operating? Even a simple "die" or "exit"
won't work because it tries to close the file descriptor and hangs!

.



Relevant Pages

  • Re: Question about pipes
    ... >> (or even pseudo code). ... > It presupposes that on your system, file descriptor zero refers ... > is attached to the read end of the pipe. ... > the child may block if there is insufficient ...
    (comp.os.linux.misc)
  • Re: Question about pipes
    ... >> (or even pseudo code). ... > It presupposes that on your system, file descriptor zero refers ... > is attached to the read end of the pipe. ... > the child may block if there is insufficient ...
    (comp.unix.programmer)
  • Re: fd redirection and gdb
    ... When A starts, A runs pipe(), then fork, redirects file descriptors, ... stopping there, it works; A speaks, B answers; all normal. ... except maybe as a gdb bug. ... as if I were writing on the wrong file descriptor after I grabbed the ...
    (comp.unix.programmer)
  • Re: Using select() with multiple threads?
    ... it will add a new file descriptor to the processing threads ... The other is not protected by a mutex and is used ... > The other is to have a pipe connecting the two threads. ... connection as well as processed connected sockets. ...
    (comp.os.linux.development.apps)
  • Need your help: Bad file descriptor and too many files open
    ... I get the following messages sometimes if i try to restart sshd: ... eval: Pipe call failed: Bad file descriptor ... Das unerlaubte Kopieren sowie die # ...
    (freebsd-questions)