[comp.windows.x] setitimer

mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) (05/09/90)

[someone had trouble with xfig dying]

> The version of xfig from the MIT distribution (1.4.3, I believe) used
> setitimer() to blink the text cursor.  That is an inherently unstable
> method of doing anything in X that uses the X library, as the library
> is not re-entrant.

Lest anyone get confused by this statement...

What this means is that you must not call Xlib routines from both the
main level and the signal-handler level; it is not a general
prohibition against using Xlib and setitimer() in the same program.
Using setitimer() to arrange calls to a signal handler is perfectly
safe (where as Xlib is concerned, at least) if the handler doesn't make
any Xlib calls itself[%].  For example,

int ticks;

sigalrm_handler()
{
 ticks ++;
}

should cause no trouble at all.

[%] The handler must of course not do anything which is unsafe even
    from the main line, such as doing read()s and write()s on the X
    connection's file descriptor.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu