Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!helios!bcm!dimacs.rutgers.edu!seismo!uunet!ora!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU Newsgroups: comp.windows.x Subject: Re: Interrupting an X program... how? Message-ID: <9103020240.AA05771@lightning.McRCIM.McGill.EDU> Date: 2 Mar 91 02:40:37 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 41 > A traditional program under Unix can be interrupted by hitting > Control-C (or whatever other character defined by stty). > How do you send a signal to an X program? The same way you send a signal to any other program. Use kill (the command or the syscall) or type one of the signal-generating characters on the process' control tty when it's in the foreground. > Specifically, a program which goes off and does lengthy calculations, > and doesn't check for X events until the calculations are complete. > Recasting this (existing) program to check for X events during the > aforesaid lengthy computations is not really an option (among other > things, the computations are in Fortran). :-( > So how can I arrange for the window manager or whatever to send a > signal to a program running in an X window? This is more or less impossible. The program may be on a different machine; it may even be running under an OS that doesn't have the notion of signals at all. In your particular case, since you have source to the program, you may be able to do something like attaching a property to your top-level window giving your process ID and some sort of machine identifier, then implementing something which checks for these and, if running on the same machine, sends the desired signal. With a bit of care (ok, with a good deal of care :-), you should be able to get away with checking for X events inside a SIGALRM handler, then arranging for SIGALRM to be delivered periodically while inside the crunching loop. (This assumes (a) that you aren't already using SIGALRM for anything, or can overload it, and (b) that you go to some trouble to make certain you don't trip over any of the landmines lurking in the use of Xlib from both mainline and signal handlers.) der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu