Strange exit behaviour of GUI programs in Xfce on Logout
Bernhard Walle
bernhard.walle at gmx.de
Sun Oct 2 00:20:45 CEST 2005
Hello,
following problem: I wrote an application which should save some
information on exit. The application doesn't use session management
(it's very simple, doesn't even have a real GUI, the connection to the
X-Server is only to get closed on logout).
The function that writes the information is registered with atexit(3).
gtk is used for the connection to the X sever.
When using other window managers, all goes fine. I tried KDE, GNOME,
WindowMaker and mwm. Only when using Xfce, the registered function is
not executed. It makes no difference if I use the session manager or the
plain Xfce login script. I use the current stable SVN 4.2.3 of Xfwm4,
the rest is 4.2.2 (tarballs).
I tracked down the problem a bit:
- Starting a failsave session (only Xterm)
- xfwm4&
- ./testclient&
- exit
=> WORKS
- Starting a failsave session
- xfwm4 --daemon
- ./testclient&
- exit
=> WORKS NOT
The test program is "attached".
Thanks for help.
Regards,
Bernhard
================================================
/*
* Compile with:
* gcc `pkg-config --cflags --libs gtk+-2.0` \
* -o testclient testclient.c
*/
#include <stdio.h>
#include <signal.h>
#include <gtk/gtk.h>
void sighandler(int sig)
{
printf("sig\n");
gtk_main_quit();
}
void last_action(void *arg)
{
printf("exit\n");
FILE* fp = fopen("/tmp/test.txt", "w");
fprintf(fp, "Test\n");
fclose(fp);
}
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
signal(SIGHUP, sighandler);
signal(SIGTERM, sighandler);
signal(SIGQUIT, sighandler);
signal(SIGINT, sighandler);
atexit(last_action);
gtk_main();
return 0;
}
================================================
(The real application is some kind of Bluetooth server to remote-control
Xfmedia from a Java mobile phone. It needs to be started by the Session
manager/.xinitrc to have a connection to D-BUS to Xfmedia. That's the
reason why it isn't a real Unix daemon.)
More information about the Xfce4-dev
mailing list