• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeinit
 

tdeinit

  • tdeinit
tdelauncher_main.cpp
1 /*
2  This file is part of the KDE libraries
3  Copyright (c) 1999 Waldo Bastian <bastian@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "config.h"
21 
22 #include <unistd.h>
23 #include <fcntl.h>
24 
25 #include "tdeapplication.h"
26 #include "tdelauncher.h"
27 #include "tdecmdlineargs.h"
28 #include "tdecrash.h"
29 #include "kdebug.h"
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <signal.h>
33 #include <tqcstring.h>
34 #include <tdelocale.h>
35 
36 #include "tdelauncher_cmds.h"
37 
38 static void sig_handler(int sig_num)
39 {
40  // No recursion
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);
45 }
46 
47 static TDECmdLineOptions options[] =
48 {
49  { "new-startup", "Internal", 0 },
50  TDECmdLineLastOption
51 };
52 
53 extern "C" TDE_EXPORT int kdemain( int argc, char**argv )
54 {
55  // Started via tdeinit.
56  if (fcntl(LAUNCHER_FD, F_GETFD) == -1)
57  {
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());
60  return 1;
61  }
62 
63  TQCString cname = TDEApplication::launcher();
64  char *name = cname.data();
65  TDECmdLineArgs::init(argc, argv, name, "TDELauncher", "A service launcher.",
66  "v1.0");
67 
68  TDELauncher::addCmdLineOptions();
69  TDECmdLineArgs::addCmdLineOptions( options );
70 
71  // WABA: Make sure not to enable session management.
72  putenv(strdup("SESSION_MANAGER="));
73 
74  // Allow the locale to initialize properly
75  TDELocale::setMainCatalogue("tdelibs");
76 
77  TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
78 
79  int maxTry = 3;
80  while(true)
81  {
82  TQCString dcopName = TDEApplication::dcopClient()->registerAs(name, false);
83  if (dcopName.isEmpty())
84  {
85  kdWarning() << "[tdelauncher] DCOP communication problem!" << endl;
86  return 1;
87  }
88  if (dcopName == cname)
89  break; // Good!
90 
91  if (--maxTry == 0)
92  {
93  kdWarning() << "[tdelauncher] Another instance of tdelauncher is already running!" << endl;
94  return 1;
95  }
96 
97  // Wait a bit...
98  kdWarning() << "[tdelauncher] Waiting for already running tdelauncher to exit." << endl;
99  sleep(1);
100 
101  // Try again...
102  }
103 
104  TDELauncher *launcher = new TDELauncher(LAUNCHER_FD, args->isSet("new-startup"));
105  launcher->dcopClient()->setDefaultObject( name );
106  launcher->dcopClient()->setDaemonMode( true );
107 
108  TDECrash::setEmergencySaveFunction(sig_handler);
109  signal( SIGHUP, sig_handler);
110  signal( SIGPIPE, SIG_IGN);
111  signal( SIGTERM, sig_handler);
112 
113  launcher->exec();
114  return 0;
115 }
116 

tdeinit

Skip menu "tdeinit"
  • Main Page
  • File List
  • Related Pages

tdeinit

Skip menu "tdeinit"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeinit by doxygen 1.9.1
This website is maintained by Timothy Pearson.