home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gossip.pyramid.com!olivea!sgigate!rutgers!sun-barr!cs.utexas.edu!wupost!csus.edu!csusac!unify!openlook!openlook-request
- From: fgreco@shearson.com (Frank Greco)
- Newsgroups: comp.windows.open-look
- Subject: xv_wait()?
- Message-ID: <6tyf1ay@openlook.Unify.Com>
- Date: 30 Jul 92 23:38:19 GMT
- Sender: news@Unify.Com
- Lines: 57
-
- I've been trying to implement xv_wait(), the XView replacement for good
- 'ole wait() without much success. I have to fork() off a child in an
- XView pgm, but must wait for its completion. I use notify_set_wait3_func()
- to handle the SIGCHLD signal of course:
-
-
- /*************************************************/
- Notify_value waitfn(me, pid, status, rusage)
- Notify_client me;
- int pid;
- union wait *status;
- struct rusage *rusage;
- {
- Notify_value value;
-
- childstatus = CHILD_INACTIVE;
-
- if ( WIFEXITED (*status) )
- return NOTIFY_DONE;
-
- return NOTIFY_IGNORED;
- }
-
-
- Then I use my xv_wait() to wait for the child to terminate while
- getting XView events.
-
- When my handler is executed (ie, when the child terminates), I set a
- "global" flag called childstatus to CHILD_INACTIVE. My xv_wait()
- merely spins around waiting for this variable to change to CHILD_INACTIVE.
-
-
- /*************************************************/
- xv_wait(delay)
- int delay; /* In microseconds ... just a dummy */
- {
- int i = 0;
-
- while( childstatus == CHILD_ACTIVE ) {
- usleep(delay);
- notify_dispatch();
- }
- }
-
- What is puzzling, is that in a non-windowing application, this
- seems to work fine (ie, using the notifier without XView). The
- minute I use this with Xview, my xv_wait() never returns.
-
- It seems that my SIGCHLD handler is never called setting the
- state variable of my child process in an XView application.
-
- Anyone see something obviously wrong with my strategy here?
-
- Thanks all,
-
- Frank G.
- =-=-=-=-=-=-=-=-=-=
-