HELP: how to safely timeout a read on a filehandle? 
Author Message
 HELP: how to safely timeout a read on a filehandle?

Hey folks... this might be a "Perl internals" question for ya:

I have a Perl 4.036 application which communicates with a number
of databases via special database-specific child processes
it opens.  These child processes issue queries to their underlying
database, and spit the results out to their stdout, which is
really a pipe back to the parent.  Thus, accessing one looks like
this:

     open(CHILD, "$childname |");
     while ($line = <CHILD>) {  
         # do stuff
     }
     close(CHILD);

Now, like all children, THESE children might be ill-behaved, and
get hung up... so, I want to put a timeout on the read in the
second line, so that if the read times out, I can GRACEFULLY
close the filehandle, kill the child, and move on to the next child.

'Trouble is, I don't know how reentrant the filehandle routines
are... for example, can a SIGALRM signal handler safely close a
filehandle, or is there a risk of it being invoked whilst Perl
is in the middle of a data structure update?  This, BTW, is the
#1 reason why poorly written signal handlers occasionally
crash C programs: programmers do stuff like attempting to use stdio
calls within the signal handler.

Any thoughts (or authoritative replies) would be appreciated.
PLEASE EMAIL TO ME; it may be awhile before I get back from
a trip, and I don't want your good responses to evaporate.  :-)
Thanqs,
   ____           __

 / __/ _/ / / , /     Hughes STX Corporation, NASA/Goddard Space Flight Cntr.
/___/_/ \  /\  /___    
        /_/ /_____/   http://www.*-*-*.com/ ~eryq/



Sat, 19 Jul 1997 07:36:28 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Help: LWP::UserAgent and unjustified read timeouts

2. select (RBITS, WBITS, EBITS, TIMEOUT) problem (polling of filehandles)

3. Q: Timeout reading from a pipe

4. SSL read timeout

5. Timeout on STDIN read?

6. LWP::UserAgent - read timeout

7. LWP::UserAgent - read timeout

8. IO::Socket::INET - Timeout for Reading or a Methode to get the Socket Status back

9. LWP::UserAgent - read timeout

10. LWP::UserAgent - read timeout

11. Reading keys in Win32 with a timeout

12. Reading pipes with timeouts

 

 
Powered by phpBB® Forum Software