[OpenIndiana-discuss] SIGKILL happens too soon upon logout of GNOME session
Jim Klimov
jimklimov at cos.ru
Sun Oct 28 08:17:58 UTC 2012
Apparently, I have underestimated the problem :(
It seems that the generic X clients do not receive any "kill signals",
because most of them are launched as "init"-parented daemons. Only a
handful of X's systemic apps (like panels) are children of the session
or window manager (gnome-session, twm, etc). As a result, when the
X-session is being closed, the Xserver is just closed and display is
rudely yanked away from most of the graphical apps who don't even
receive any warning and can't try to begin their graceful shutdowns.
Is there any standard reliable way to "ps-grep" for local clients of
a particular X server (DISPLAY)? The terminal field in "ps" output is
undefined for most of X-clients.
Possibly, I can try to find all children of init (or zsched) and run
pargs on them to check processes' env-vars for DISPLAY=$DISPLAY, but
is there any more sane way (like a requestable list of clients of the
X-server)?
Alternately, can the Xserver signal its Xclients that it is going to
die soon, so they can process this as an OS signal or even present
an interactive close dialog (like the reaction to window-manager's
close buttons or the GUI programs' own Close/Quit menu items)?
Thanks,
//Jim Klimov
2012-10-27 15:53, Jim Klimov wrote:
> Hello all,
>
> I'm trying to write a program that would properly close itself
> upon SIGTERM, SIGINT, SIGQUIT and similar signals, in particular
> during user's exit from an X session such as GNOME.
>
> (To be more specific, I'm expanding my vboxsvc framework to cause
> proper shutdown or savestate of VMs that a user runs interactively
> in GUI mode - and either of these procedures takes at least a few
> seconds)
>
> What I see in practice is that when I log out from GNOME I see
> a warning dialog (Do you want to log out now or switch the user?)
> and when I confirm the logout, the program is terminated almost
> instantly. I think a SIGTERM is sent out to each process spawned
> by the X console, but is followed by a SIGKILL a second or two
> afterwards. My script does trap the first signal and begins VM
> stop, but finds that the VM process is already "aborted".
> My script does work as planned when I just CTRL+C in it or close
> the terminal that runs it - it saves the launched VM instead of
> aborting it.
>
> Is it possible to set a larger delay between initiation of X
> session ripdown (and does it send only SIGTERM?) and the ultimate
> unconditional SIGKILLing spree, and/or disable the latter until
> all X processes die properly as asked by SIGTERM? For example,
> Windows displays a nice dialog with the list of remaining live
> programs, a timer until forced logout/poweroff, and an option
> to either abort the logout or to force it now. Anything similar
> in OI or generic GNOME?
>
> I think (partially) suitable options are defined for the
> gnome-session-save program, but I don't yet see how that can
> be configured at startup of the gdm service (or it does not
> have to be?)
>
Thanks,
//Jim Klimov
More information about the OpenIndiana-discuss
mailing list