home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 3847 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  1.8 KB

  1. Path: sparky!uunet!sun-barr!decwrl!csus.edu!beach.csulb.edu!nic.csu.net!koko.csustan.edu!rat!zeus!kwang
  2. Newsgroups: comp.unix.programmer
  3. Subject: SIGIO & sockets.  is this right?
  4. Message-ID: <1992Jul22.004846.220119@zeus.calpoly.edu>
  5. From: kwang@zeus.calpoly.edu (Kevin Wang aka The Scarecrow)
  6. Date: Wed, 22 Jul 1992 00:48:46 GMT
  7. Organization: The Outland Riders
  8. Lines: 46
  9.  
  10. I am trying to use fcntl() to turn on O_ASYNC so that my program
  11. will receive a SIGIO when any data comes in across any of its sockets.
  12. However, it doesn't seem to be working.
  13.  
  14. system is AIX (yes, yes, I know) V 1.2.1
  15.  
  16. Here's how I turn it on:
  17.  void SIGIO_ON(int sock)
  18. {
  19.     int hold;
  20.  
  21.     hold = fcntl(sock, F_GETFL, 0);
  22.     hold = fcntl(sock, F_SETFL, hold | O_ASYNC);
  23.     if (-1 == hold)
  24.         {
  25.         perror("SIGIO_ON");
  26.         }
  27.     return;
  28. }
  29.  
  30.  
  31. and here's the code that's supposed to be interrupted by the SIGIO:
  32.         wakeupcall = FALSE;
  33.         signal(SIGALRM, AlarmHandler);
  34.         signal(SIGIO, AlarmHandler);
  35.         alarm(30);  /* wake me up in 30 seconds */
  36.         loop = AcceptConnect(sock, addr, addrlen);
  37.         errsave = errno;
  38.         signal(SIGIO, SIG_IGN);
  39.         signal(SIGALRM, SIG_IGN);  /* ignore alarms */
  40.         alarm(0);  /* cancel alarm */
  41.  
  42. all that AlarmHandler does is sets wakeupcall, a global int to TRUE,
  43. so that I know a signal occurred.
  44.  
  45. inside of AcceptConnect lies the accept() for sockets.  the man pages
  46. says it will return -1 if interrupted by a signal.  why isn't it being
  47. interrupted?
  48.  
  49.    - Kevin Wang 
  50. ...And now, for your local station identification, on the hour, every hour...
  51. kwang@hermes.calpoly.edu or kwang@gauss.elee.calpoly.edu
  52. ---
  53.    A source is a source, of course of course,  Unless, of course, the 
  54.    source is a curse;  And if, of course, the source is a curse,  Then a 
  55.    termcap entry's required.
  56.