[comp.windows.x] Signals and X--a problem

marko@mead.UUCP (Mark Osbourne) (08/01/90)

We are currently working on an X Toolkit based program.  This program
receives signals every half-second, or so, because there is input to
be read.  In the signal routine, the data is read and then written to
an X window.

The problem we're having seems to be that the Xlib functions to create
the request for the server are being interrupted by another signal.
The errors we end up getting are mostly bad request, but others like
bad drawable occasionally show up.

Is this what's happening?  How can we guarantee that the Xlib
functions are not interrupted by other signals (short of resetting and
setting them again)?

______________________________________________________________________
Mark Osbourne         marko@mead.UUCP          marko%mead@uccba.uc.edu

klee@wsl.dec.com (Ken Lee) (08/01/90)

In article <1028@meaddata.mead.UUCP>, marko@mead.UUCP (Mark Osbourne) writes:
|> The problem we're having seems to be that the Xlib functions to create
|> the request for the server are being interrupted by another signal.
|> The errors we end up getting are mostly bad request, but others like
|> bad drawable occasionally show up.

A few things you might try:

1.  Xlib has LockDisplay macros around critical sections of code.  You
could try defining these to block signals.

2.  Don't do Xlib things in your signal handlers.  Instead, set a flag
and do you X stuff afterwards.

3.  Open 2 server connections.  Do your normal X stuff on 1 connection
and your signal handler stuff on the other.  This assumes, of course,
that you can prevent signals handlers from interrupting each other.

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