25 #include "tdeapplication.h"
26 #include "tdelauncher.h"
27 #include "tdecmdlineargs.h"
33 #include <tqcstring.h>
34 #include <tdelocale.h>
36 #include "tdelauncher_cmds.h"
38 static void sig_handler(
int sig_num)
41 signal( SIGHUP, SIG_IGN);
42 signal( SIGTERM, SIG_IGN);
43 fprintf(stderr,
"[tdelauncher] Exiting on signal %d\n", sig_num);
44 TDELauncher::destruct(255);
47 static TDECmdLineOptions options[] =
49 {
"new-startup",
"Internal", 0 },
53 extern "C" TDE_EXPORT
int kdemain(
int argc,
char**argv )
56 if (fcntl(LAUNCHER_FD, F_GETFD) == -1)
58 fprintf(stderr,
"%s", i18n(
"[tdelauncher] This program is not supposed to be started manually.\n"
59 "[tdelauncher] It is started automatically by tdeinit.\n").local8Bit().data());
63 TQCString cname = TDEApplication::launcher();
64 char *name = cname.data();
65 TDECmdLineArgs::init(argc, argv, name,
"TDELauncher",
"A service launcher.",
68 TDELauncher::addCmdLineOptions();
69 TDECmdLineArgs::addCmdLineOptions( options );
72 putenv(strdup(
"SESSION_MANAGER="));
75 TDELocale::setMainCatalogue(
"tdelibs");
77 TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
82 TQCString dcopName = TDEApplication::dcopClient()->registerAs(name,
false);
83 if (dcopName.isEmpty())
85 kdWarning() <<
"[tdelauncher] DCOP communication problem!" << endl;
88 if (dcopName == cname)
93 kdWarning() <<
"[tdelauncher] Another instance of tdelauncher is already running!" << endl;
98 kdWarning() <<
"[tdelauncher] Waiting for already running tdelauncher to exit." << endl;
104 TDELauncher *launcher =
new TDELauncher(LAUNCHER_FD, args->isSet(
"new-startup"));
105 launcher->dcopClient()->setDefaultObject( name );
106 launcher->dcopClient()->setDaemonMode(
true );
108 TDECrash::setEmergencySaveFunction(sig_handler);
109 signal( SIGHUP, sig_handler);
110 signal( SIGPIPE, SIG_IGN);
111 signal( SIGTERM, sig_handler);