[comp.windows.x] how to trap f.kill

tony@sat.uucp (01/22/91)

I need to trap the f.kill issued by the window manager (at user command)
and do some cleaning up before my application exits; is there any way to 
trap this "event or signal" ?

any responses will be greatly appreciated !!
-- 
Tony Leung  vsi1!sat!tony    tony%sat@vicom.com

evans@decvax.DEC.COM (Marc Evans) (01/25/91)

In article <1991Jan22.010234.15702@sat.uucp>, tony@sat.uucp writes:
|> I need to trap the f.kill issued by the window manager (at user command)
|> and do some cleaning up before my application exits; is there any way to 
|> trap this "event or signal" ?

Use the XSetIOErrorHandler function to set up a function to be called when
the Fatal IO error occurs, one of which would be a server disconnection. You
will need to be careful here, in that the only other X calls you should make
are to free memory. The function is not expected to return, so be sure that
it doesn't.

- Marc
-- 
===========================================================================
Marc Evans - WB1GRH - evans@decvax.DEC.COM  | Synergytics     (603)635-8876
      Unix and X Software Contractor        | 21 Hinds Ln, Pelham, NH 03076
===========================================================================

dex@hpcvlx.cv.hp.com (Dex Smith) (01/26/91)

See "question 2" in a responce to a note relating to WM_SAVE_YOURSELF
later in this notestring.

- Dex Smith
  Hewlett-Packard Company

tjhorton@vis.toronto.edu ("Timothy J. Horton") (01/27/91)

tony@sat.uucp writes:
> I need to trap the f.kill issued by the window manager (at user command)
> and do some cleaning up before my application exits; is there any way to 
> trap this "event or signal" ?

f.kill processing works via ICCM (Inter-Client Communication).
What you have to do is XIternAtom "WM_DELETE_WINDOW", and add
a protocol callback for that atom.  Sorry that I don't know
the code offhand (left it at my last contract site).  Keep in
mind that after your callback returns control, the mainLoop exits.

This does not trap loss of connection to the server (although
you didn't ask specifically, it seems necessary).  That half
of a good solution was given earlier  by someone else:

evans@decvax.DEC.COM writes:
>Use the XSetIOErrorHandler function to set up a function to be called when
>the Fatal IO error occurs, one of which would be a server disconnection. You
>will need to be careful here, in that the only other X calls you should make
>are to free memory. The function is not expected to return, so be sure that
>it doesn't.