Re: how to close a stalled file descriptor?




Quoth Glenn <eponymousalias@xxxxxxxxx>:
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.

Which OS are you using? Under most Unices, a writing to a full pipe with
no readers will first send SIGPIPE, and if that is handled or ignored,
fail with EPIPE.

But if the signal handler is invoked and I regain
control, on any subsequent attempt to close the file descriptor,
it stalls again!

When you say 'file descriptor' do you mean 'Perl file handle'? Which
perl version are you using? Are you using PerlIO? It's possible that you
are closing a Perl FH, which is attempting to flush its buffers and
handling the error badly. If this is the case, then you may be able to
ignore (and lose) the buffer by pushing a :unix layer before you close.

Ben

.



Relevant Pages

  • Re: how to close a stalled file descriptor?
    ... To unblock myself if the write takes too long because the pipe is full ... be written to before any reader has attached to the pipe. ... When you say 'file descriptor' do you mean 'Perl file handle'? ... Yes, it seems like the Perl FH, in trying to flush its buffers, is ...
    (comp.lang.perl.misc)
  • Re: Windows 7 USB lockup after selective suspend resume
    ... I am having problems with the x86 Windows 7/WDF 1009 version of the driver under scenarios where a request is received in a power managed queue within 2-3 milliseconds of the WDF USB driver completing its EvtDeviceD0Exit routine. ... Write request forwarded to USB pipe IO target ... Reader for pipe #1 restarted ...
    (microsoft.public.development.device.drivers)
  • Re: Windows 7 USB lockup after selective suspend resume
    ... it does appear from the trace that there was an attempt to enter selective suspend at 188.505. ... EvtDeviceSelfManagedIoSuspend routine entered ... Write request forwarded to USB pipe IO target ... Reader for pipe #1 restarted ...
    (microsoft.public.development.device.drivers)
  • Windows 7 USB lockup after selective suspend resume
    ... I have a KMDF USB driver for a network device that supports selective suspend ... Write request forwarded to USB pipe IO target ... Reader for pipe #1 restarted ...
    (microsoft.public.development.device.drivers)
  • Re: Pthread fd and memory leak
    ... and closes the socket file descriptor. ... When you send an fd over a pipe, the fd is still open in the sending ... memory at the pointer value and free it without errors, ...
    (comp.programming.threads)