Path: utzoo!attcan!uunet!snorkelwacker!bloom-beacon!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.programmer Subject: Re: Hey, what about SIGIO? Message-ID: <1990Sep26.184409.10155@athena.mit.edu> Date: 26 Sep 90 18:44:09 GMT References: Sender: daemon@athena.mit.edu (Mr Background) Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Distribution: comp Organization: Massachusetts Institute of Technology Lines: 30 In article , lush@EE.MsState.Edu (Edward Luke) writes: |> I would like to get a signal when new data arrives on an |> input file descriptor, or when an output file descriptor is free to be |> filled again. Is it possible for me to do this without using fork() |> to start another process to monitor the file descriptor? Can I tell |> the OS to give me a SIGIO when there is a pending condition on a |> socket? Just what is the SIGIO signal for? See the man page fcntl(2). You want to use the F_SETOWN fcntl call on the file descriptor and set the ownership to your PID, and then use the FASYNC fcntl to turn on asynchronous I/O; when ASYNC is enabled, and input comes in on the file descriptor, your process will get SIGIO. I'm not certain that you'll get SIGIO if there is room for writing in a pipe; I've never used it for that, and fcntl(2) only mentions data waiting to be read when it mentions FASYNC, so I don't know whether or not it'll work. Oh, you'll also get SIGURG when there is an "urgent condition" on a socket; I'm not completely sure what an "urgent condition" is, perhaps that's what they call a premature closing of the other end of the socket or something. One more thing -- I believe that if the other end of the FD is closed, you'll get a SIGIO, and then when you read, you'll get 0 bytes, thus signalling EOF. -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710