36 #include <QtCore/QCoreApplication>
38 #ifndef USE_KPROCESS_FOR_KIOSLAVES
39 static int sigpipe[ 2 ];
40 static void sig_handler(
int sig_num)
43 KDE_signal( SIGHUP, SIG_IGN);
44 KDE_signal( SIGTERM, SIG_IGN);
45 fprintf(stderr,
"klauncher: Exiting on signal %d\n", sig_num);
47 write( sigpipe[ 1 ], &tmp, 1 );
51 #if defined(Q_OS_DARWIN) || defined (Q_OS_MAC)
60 if (argc != 2 || memcmp(argv[1],
"--fd=", 5) || !(launcherFd = atoi(argv[1] + 5)))
62 fprintf(stderr,
"%s",
i18n(
"klauncher: This program is not supposed to be started manually.\n"
63 "klauncher: It is started automatically by kdeinit4.\n").toLocal8Bit().data());
68 #if defined(Q_OS_DARWIN) || defined (Q_OS_MAC)
76 putenv(strdup(
"SESSION_MANAGER="));
79 QCoreApplication app(argc, argv);
85 QString service(QLatin1String(
"org.kde.klauncher"));
86 if (!QDBusConnection::sessionBus().isConnected()) {
87 kWarning() <<
"No DBUS session-bus found. Check if you have started the DBUS server.";
90 QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply =
91 QDBusConnection::sessionBus().interface()->registerService(service);
94 kWarning() <<
"DBUS communication problem!";
97 if (reply == QDBusConnectionInterface::ServiceRegistered)
102 kWarning() <<
"Another instance of klauncher is already running!";
107 kWarning() <<
"Waiting for already running klauncher to exit.";
113 #ifndef USE_KPROCESS_FOR_KIOSLAVES
118 QDBusConnection::sessionBus().registerObject(QString::fromLatin1(
"/"), launcher);
120 #ifndef USE_KPROCESS_FOR_KIOSLAVES
121 if (pipe(sigpipe) != 0) {
122 perror(
"klauncher: pipe failed.");
125 QSocketNotifier* signotif =
new QSocketNotifier( sigpipe[ 0 ], QSocketNotifier::Read, launcher );
126 QObject::connect( signotif, SIGNAL(activated(
int)), launcher, SLOT(destruct()));
127 KCrash::setEmergencySaveFunction(sig_handler);
128 KDE_signal( SIGHUP, sig_handler);
129 KDE_signal( SIGPIPE, SIG_IGN);
130 KDE_signal( SIGTERM, sig_handler);
QString i18n(const char *text)
QDebug perror(QDebug s, KDebugTag)
QString componentName() const
int kdemain(int argc, char **argv)
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void mac_initialize_dbus()