home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / windows / openloo / 3297 < prev    next >
Encoding:
Text File  |  1992-07-30  |  1.8 KB  |  67 lines

  1. Path: sparky!uunet!gossip.pyramid.com!olivea!sgigate!rutgers!sun-barr!cs.utexas.edu!wupost!csus.edu!csusac!unify!openlook!openlook-request
  2. From: fgreco@shearson.com (Frank Greco)
  3. Newsgroups: comp.windows.open-look
  4. Subject: xv_wait()?
  5. Message-ID: <6tyf1ay@openlook.Unify.Com>
  6. Date: 30 Jul 92 23:38:19 GMT
  7. Sender: news@Unify.Com
  8. Lines: 57
  9.  
  10. I've been trying to implement xv_wait(), the XView replacement for good
  11. 'ole wait() without much success.  I have to fork() off a child in an
  12. XView pgm, but must wait for its completion.  I use notify_set_wait3_func()
  13. to handle the SIGCHLD signal of course:
  14.  
  15.  
  16. /*************************************************/
  17. Notify_value waitfn(me, pid, status, rusage)
  18. Notify_client me;
  19. int pid;
  20. union wait *status;
  21. struct rusage *rusage;
  22. {
  23.     Notify_value value;
  24.  
  25.     childstatus = CHILD_INACTIVE;
  26.  
  27.     if ( WIFEXITED (*status) )
  28.         return NOTIFY_DONE;
  29.  
  30.     return NOTIFY_IGNORED;
  31. }
  32.  
  33.  
  34. Then I use my xv_wait() to wait for the child to terminate while
  35. getting XView events.
  36.  
  37. When my handler is executed (ie, when the child terminates), I set a
  38. "global" flag called childstatus to CHILD_INACTIVE.  My xv_wait()
  39. merely spins around waiting for this variable to change to CHILD_INACTIVE.
  40.  
  41.  
  42. /*************************************************/
  43. xv_wait(delay)
  44. int delay;              /* In microseconds ... just a dummy */
  45. {
  46.     int i = 0;
  47.  
  48.     while( childstatus == CHILD_ACTIVE ) {
  49.         usleep(delay);
  50.         notify_dispatch();
  51.     }
  52. }
  53.  
  54. What is puzzling, is that in a non-windowing application, this
  55. seems to work fine (ie, using the notifier without XView).  The 
  56. minute I use this with Xview, my xv_wait() never returns.
  57.  
  58. It seems that my SIGCHLD handler is never called setting the
  59. state variable of my child process in an XView application.
  60.  
  61. Anyone see something obviously wrong with my strategy here?
  62.  
  63. Thanks all,
  64.  
  65. Frank G.
  66. =-=-=-=-=-=-=-=-=-=
  67.