signals and X

signals and X

Post by Simon Oldfie » Sat, 23 Nov 1991 07:49:26



        I have an Xlib program which does the following :-

int Signal = 0;
void SignalHandler();

main()
{
        switch( fork() )
                {
                case 0:
                        signal( SIGUSR1,SignalHandler );
                        XOpenDisplay( display );
                        ...
                        XMapWindow(...);
                        do
                                {
                                XNextEvent( display,report );
                                ...
                                }
                        while ( Signal==0 );
                        XUnmapWindow(..);
                        ...
                        XCloseDisplay(...);
                }

Quote:}

void
SignalHandler()
{
        Signal = 1;

Quote:}

        So what happens I would like to happen is that the forked process
should exit "nicely" upon receipt of the signal but it gets stuck in the
XNextEvent call until it receives an event at which time it exits.

        Can anyone tell me how to get it to exit immediately ?

        I tried using XCheckWindowEvent instead of XNextEvent but continually
going through the while loop is rather hungry on cpu time !!

Please Reply by email
Thanks in advance
Simon Oldfield