*BSD News Article 53335


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.uwa.edu.au!classic.iinet.com.au!swing.iinet.net.au!news.uoregon.edu!xmission!news.cc.utah.edu!news.cs.utah.edu!caen!spool.mu.edu!howland.reston.ans.net!newsfeed.internetmci.com!news.sesqui.net!uuneo.neosoft.com!nmtigw!zuul.nmti.com!peter
From: peter@nmti.com (Peter da Silva)
Newsgroups: comp.unix.bsd.misc
Subject: Re: READ(2) timeout after minutes?
Date: 19 Oct 1995 16:24:14 GMT
Organization: Network/development platform support, NMTI
Lines: 26
Message-ID: <465u3e$pb3@zuul.nmti.com>
References: <460c28$776@bdanwb.knmi.nl>
NNTP-Posting-Host: sonic.nmti.com

In article <460c28$776@bdanwb.knmi.nl>, Johan Holtman <rtholtma@knmi.nl> wrote:
> Suppose the read(2) system call takes a very long time (eg, because of
> a file being archived).

Elaborate on "a file being archived".

> HOW can I MAKE read(2) timeout after X minutes?

Longjmp out of the signal handler.

> Q1. How can I set a timeout on read for eg. 5 minutes?

> I tried to do this with alarm() and signal(). This signal is send
> DURING the read, but only processed AFTER the read system call.

No, it's processed during the read, but the read is resumed.

> Q2. How come? Other signals are directly handled?

No, they're not. They all work the same. It's just that sometimes the signal
is the result of an event that independently terminates the read.
-- 
Peter da Silva    (NIC: PJD2)      `-_-'             1601 Industrial Boulevard
Bailey Network Management           'U`             Sugar Land, TX  77487-5013
+1 713 274 5180         "Har du kramat din varg idag?"                     USA
Bailey pays for my technical expertise.        My opinions probably scare them