[comp.windows.x] mainloop and signals

pcb@gator.cacs.usl.edu (Peter C. Bahrs) (03/09/90)

 > In article <23695@masscomp.ccur.com> mitch@westford.ccur.com (Mitchel Kuninsky) writes:
 > :I envision a signal handler like:
 > :
 > :	SignalHandler
 > :	{
 > :	    sigFlag = TRUE;
 > :	}
 > :
 > :and an XtMainLoop like:
 > :
 > :	MyMainLoop()
 > :	{
 > :	    XEvent event;
 > :
 > :	    for (;;)
 > :	    {
 > :(1)		XtNextEvent( &event );
 > :		if (event.type != NULL_EVENT)	/* or something like this. */
 > :		    XtDispatchEvent( &event );
 > :		if (sigFlag)
 > :		{
 > :		    process signal.
 > :		    Inhibit signals.
 > :		    sigFlag = FALSE;
 > :(2)		    Enable signals.
 > :		}
 > :	    }
 > :	}
 > 
 > This may be kind of nit-picking, but ... You have a nasty race here.
 > What if a signal arrives between the re-enabling of signals at (2) and
 > the next call to XtNextEvent at (1).
 > 
 > I believe this points out the need to have the signal-handling more
 > tightly integrated with the Intrinsics code.
 > 
I would like to do a similar thing...instead of using signals I want to
do a select on sockets.  Any comments or suggestions as to get this 
more 'tightly integrated...' with Intrinsics?


/*----------- Thanks in advance... --------------------------------------+
| Peter C. Bahrs                                                         |
| The USL-NASA Project                                                   |
| Center For Advanced Computer Studies      INET: pcb@gator.cacs.usl.edu |
| 2 Rex Street                                                           |
| University of Southwestern Louisiana      ...!uunet!dalsqnt!gator!pcb  | 
| Lafayette, LA 70504                                                    |
+-----------------------------------------------------------------------*/

klee@wsl.dec.com (Ken Lee) (03/09/90)

In article <5007@rouge.usl.edu>, pcb@gator.cacs.usl.edu (Peter C. Bahrs)
writes:
> I would like to do a similar thing...instead of using signals I want to
> do a select on sockets. 

Did you try XtAppAddInput?

Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

mikeo@sae.UUCP (Michael Ovington) (03/12/90)

>> I would like to do a similar thing...instead of using signals I want to
>>do a select on sockets.  Any comments or suggestions as to get this
>>more 'tightly integrated...' with Intrinsics?


   Take a look at the documentation for
      XtAddInput()    which is the old fashioned form of
      XtAppAddInput() (we've been using this a long time.)

   It registers a new source of events with Xt. You can pass in the socket
   and recieve callback events when there is something to be read on the socket.
   ________________________________________________________________________
   Michael S. Ovington 			Software Architecture & Engineering
   (703) 276-7910			1600 Wilson Blvd, Suite 500
   uunet!sae!mikeo			Arlington, VA 22209
   ________________________________________________________________________