home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!mentor.cc.purdue.edu!noose.ecn.purdue.edu!ecn.purdue.edu!kudva
- From: kudva@ecn.purdue.edu (Gautham K. Kudva)
- Newsgroups: comp.unix.programmer
- Subject: SIGALRM handlers and sleep
- Message-ID: <1992Sep14.203355.20114@noose.ecn.purdue.edu>
- Date: 14 Sep 92 20:33:55 GMT
- Sender: news@noose.ecn.purdue.edu (USENET news)
- Distribution: usa
- Organization: Purdue University Engineering Computer Network
- Lines: 23
-
-
- I'm trying to write a program that needs to interlace computations with
- communications. The platform is a Sun SPARC IPC running SunOS 4.1, though
- I'd like to keep the code as portable as possible. Previously I was using
- Sun's lwp package, but a bug in their code put paid to those plans. Now
- I'm trying to use signals. I'm installing a handler for SIGALRM and set
- alarms at uniform intervals. Compuatations go on as usual. Whenever the
- SIGALRM handler is called, it executes the communication code. Things
- work out ok till I use a sleep() call. The call uses its own signal
- handler, and things get screwy. Rochkind does not mention anything about
- this. Richard Stevens' "UNIX Network Programming" says that sleep can
- interact with a process' own SIGALRM handlers; but no details are given.
- I haven't found anything on these lines in the man pages either. So is there
- any way in which my signal handler can peacefully co-exist with sleep()?
- Or do I need to replace all sleep calls (using defines or something)
- with my custom sleep function which handles alarms right? I don't like
- the latter option, since I could be using pre-compiled code that contains
- calls to sleep. References to any book that addresses this issue would
- also be great.
-
- Thanks in advance,
- Gautham Kudva
- kudva@ecn.purdue.edu
-