home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!caen!nic.umass.edu!dime!patrick
- From: patrick@themis.cs.umass.edu (Patrick Healy)
- Newsgroups: comp.unix.programmer
- Subject: handling SIGCHLD correctly and reusing broadcast sockets
- Message-ID: <52042@dime.cs.umass.edu>
- Date: 19 Aug 92 00:06:22 GMT
- Sender: news@dime.cs.umass.edu
- Reply-To: patrick@themis.cs.umass.edu (Patrick Healy)
- Organization: University of Massachusetts, Amherst
- Lines: 49
-
-
-
- M/C: DECstation 5000; OS: Ultrix 4.2c
-
-
- Two questions:
-
- (1) How do I correctly handle SIGCHLD signals from exiting children?
- (2) Can I use the same UDP port to both receive a broadcast and respond to
- the broadcast?
-
- Elabortions:
-
- (1) In a server I'm building, I would like to know when a forked off process
- completes so that I can check its exit status and wait() on it. So I handle
- the SIGCHLD by wait3() and check the status of each of my processes, onyl
- paying attention to the processes that have exited since I last called
- wait3().
-
- My problem with this scheme is that program may be in the middle of a system
- call to what Stevens calls a "slow device." The system call (e.g, accept()) is
- interrupted and I now have to deal restarting the system call etc. Can people
- tell me if there is a more elegant way of allowing me to handle the SIGCHLD
- without having to go back and modify my every accept, read and write to that it
- handles the interrupt in the correct way. Right now, rather than deal with
- that I have just decided to wait until a new request comes in before I wait3()
- on the old one. Thus, I always have one <exiting> process lying around.
-
-
- (2) How can I use *one* datagram socket to broadcast a message and receive a
- response on the same socket?
-
- When my client starts up, it won't know where the server currently resides.
- So the first thing it does is sends out a broadcast asking that the server
- make itelf known to it. I would now like the server to reply (and send a
- small amount of other configuration information) using the *same* socket. Can
- this be done? It would seem to require setting/resetting SO_BROADCAST on the
- socket, but anything more than that I can't figure out.
-
-
-
- Answers or comments to either of these questions would be greatly appreciated.
-
- Thanks,
- Paddy Healy.
-
- ===============================================================================
- Patrick Healy: patrick@themis.cs.umass.edu
- Guest of: CS Department
-