Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!ames!uhccux!munnari.oz.au!labtam!davidp From: davidp@labtam.oz (David Purdue) Newsgroups: comp.windows.x Subject: Re: SysV, signals and X Message-ID: <1796@labtam.oz> Date: 21 Sep 89 02:50:22 GMT References: <2400@goanna.oz> Organization: Labtam Information Systems Pty Ltd, Melbourne, Australia Lines: 38 From article <2400@goanna.oz>, by dmh@goanna.oz (Darren Hosking): > Due to the nature of System V signal handling it is possible for system > calls within an X library (specifically Xlib) to be interrupted, ie the > system call that was interrupted will return an error (-1) and errno will > be set to EINTR. > > How can you use signal() and your own signal handlers without the client > generating an error message and exiting (because of the interrupted syscall)? > > For example, if you want to run an infinite loop of X calls (drawing > rectangles or whatever) which is stopped by a SIGALRM and a signal handler, > how can you guarantee that system calls within Xlib (or other X libraries) > will not be interrupted and abort? I just came across this problem while trying to do a benchmark with xbench. The situation is exactly as in the example above. What I do is this: I set up the signal handling routine using setsig(2), then around the call to Xlib in the relevant loop I put sighold(2) and sigrelse(2). Thus signal handling is turned off while X does its stuff. I have found that the system call overhead for doing this is not prohibitive, and it does not affect the xbench results because xbench always completes its operation before checking if the alarm went off anyway. DavidP ==== Mr. David Purdue Phone ISD: +61 3 587 1444 Fax: +61 3 580 5581 Labtam Information Telex: LABTAM AA33550 Systems Pty Ltd, 43 Malcolm Road, ACSnet/CSnet: davidp@labtam.oz BRAESIDE, ARPA: davidp%labtam.oz@uunet.uu.net VICTORIA, 3195. JANET: davidp@oz.labtam AUSTRALIA UUCP: ...!uunet!munnari!labtam.oz!davidp "Maybe I think too much." - Paul Simon