summaryrefslogtreecommitdiff
path: root/core/launcher
authormickeyl <mickeyl>2004-11-12 13:51:35 (UTC)
committer mickeyl <mickeyl>2004-11-12 13:51:35 (UTC)
commitde558d6f0bc31f58ffaa894a0236f0d9cb5d73e0 (patch) (unidiff)
tree55f7c2ec8c1e93983d41c962e557f3651db39b03 /core/launcher
parentee67d61c20b6840f3fb353e314d16a90c0438e7c (diff)
downloadopie-de558d6f0bc31f58ffaa894a0236f0d9cb5d73e0.zip
opie-de558d6f0bc31f58ffaa894a0236f0d9cb5d73e0.tar.gz
opie-de558d6f0bc31f58ffaa894a0236f0d9cb5d73e0.tar.bz2
handle more signals and don't kill the process @ end
Diffstat (limited to 'core/launcher') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/main.cpp92
1 files changed, 37 insertions, 55 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index b119399..aa0dfdf 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -66,7 +66,7 @@ static void cleanup()
66 QStringList stale = dir.entryList(); 66 QStringList stale = dir.entryList();
67 QStringList::Iterator it; 67 QStringList::Iterator it;
68 for ( it = stale.begin(); it != stale.end(); ++it ) { 68 for ( it = stale.begin(); it != stale.end(); ++it ) {
69 dir.remove( *it ); 69 dir.remove( *it );
70 } 70 }
71} 71}
72 72
@@ -87,7 +87,7 @@ void initEnvironment()
87 87
88 // if not timezone set, pick New York 88 // if not timezone set, pick New York
89 if (tz.isNull() || tz.isEmpty()) 89 if (tz.isNull() || tz.isEmpty())
90 tz = "America/New_York"; 90 tz = "America/New_York";
91 91
92 setenv( "TZ", tz, 1 ); 92 setenv( "TZ", tz, 1 );
93 config.writeEntry( "Timezone", tz); 93 config.writeEntry( "Timezone", tz);
@@ -95,7 +95,7 @@ void initEnvironment()
95 config.setGroup( "Language" ); 95 config.setGroup( "Language" );
96 QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); 96 QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace();
97 if( lang.isNull() || lang.isEmpty()) 97 if( lang.isNull() || lang.isEmpty())
98 lang = "en_US"; 98 lang = "en_US";
99 99
100 setenv( "LANG", lang, 1 ); 100 setenv( "LANG", lang, 1 );
101 config.writeEntry("Language", lang); 101 config.writeEntry("Language", lang);
@@ -125,7 +125,7 @@ static void initKeyboard()
125 int ard = config.readNumEntry( "RepeatDelay" ); 125 int ard = config.readNumEntry( "RepeatDelay" );
126 int arp = config.readNumEntry( "RepeatPeriod" ); 126 int arp = config.readNumEntry( "RepeatPeriod" );
127 if ( ard > 0 && arp > 0 ) 127 if ( ard > 0 && arp > 0 )
128 qwsSetKeyboardAutoRepeat( ard, arp ); 128 qwsSetKeyboardAutoRepeat( ard, arp );
129 129
130 QString layout = config.readEntry( "Layout", "us101" ); 130 QString layout = config.readEntry( "Layout", "us101" );
131 Server::setKeyboardLayout( layout ); 131 Server::setKeyboardLayout( layout );
@@ -141,13 +141,13 @@ static bool firstUse()
141 } 141 }
142 142
143 { 143 {
144 Config config( "qpe" ); 144 Config config( "qpe" );
145 config.setGroup( "Startup" ); 145 config.setGroup( "Startup" );
146 needFirstUse |= config.readBoolEntry( "FirstUse", TRUE ); 146 needFirstUse |= config.readBoolEntry( "FirstUse", TRUE );
147 } 147 }
148 148
149 if ( !needFirstUse ) 149 if ( !needFirstUse )
150 return FALSE; 150 return FALSE;
151 151
152 FirstUse *fu = new FirstUse(); 152 FirstUse *fu = new FirstUse();
153 fu->exec(); 153 fu->exec();
@@ -175,15 +175,15 @@ int initApplication( int argc, char ** argv )
175 175
176 // Don't use first use under Windows 176 // Don't use first use under Windows
177 if ( firstUse() ) { 177 if ( firstUse() ) {
178 a.restart(); 178 a.restart();
179 return 0; 179 return 0;
180 } 180 }
181 181
182 ODevice::inst ( )-> setSoftSuspend ( true ); 182 ODevice::inst ( )-> setSoftSuspend ( true );
183 183
184 { 184 {
185 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 185 QCopEnvelope e("QPE/System", "setBacklight(int)" );
186 e << -3; // Forced on 186 e << -3; // Forced on
187 } 187 }
188 188
189 AlarmServer::initialize(); 189 AlarmServer::initialize();
@@ -223,70 +223,52 @@ static const char *pidfile_path = "/var/run/opie.pid";
223 223
224void create_pidfile ( ) 224void create_pidfile ( )
225{ 225{
226 FILE *f; 226 FILE *f;
227 227
228 if (( f = ::fopen ( pidfile_path, "w" ))) { 228 if (( f = ::fopen ( pidfile_path, "w" ))) {
229 ::fprintf ( f, "%d", getpid ( )); 229 ::fprintf ( f, "%d", getpid ( ));
230 ::fclose ( f ); 230 ::fclose ( f );
231 } 231 }
232} 232}
233 233
234void remove_pidfile ( ) 234void remove_pidfile ( )
235{ 235{
236 ::unlink ( pidfile_path ); 236 ::unlink ( pidfile_path );
237} 237}
238 238
239void handle_sigterm ( int /* sig */ ) 239void handle_sigterm ( int /* sig */ )
240{ 240{
241 if ( qApp ) 241 ::signal( SIGCHLD, SIG_IGN );
242 qApp-> quit ( ); 242 ::signal( SIGSEGV, SIG_IGN );
243 ::signal( SIGBUS, SIG_IGN );
244 ::signal( SIGILL, SIG_IGN );
245 ::signal( SIGTERM, SIG_IGN );
246 ::signal ( SIGINT, SIG_IGN );
247 if ( qApp ) qApp->quit();
243} 248}
244 249
245#ifndef Q_OS_WIN32
246int main( int argc, char ** argv ) 250int main( int argc, char ** argv )
247{ 251{
248 252 ::signal( SIGCHLD, SIG_IGN );
249 ::signal ( SIGCHLD, SIG_IGN ); 253 ::signal( SIGSEGV, handle_sigterm );
250 254 ::signal( SIGBUS, handle_sigterm );
251 ::signal ( SIGTERM, handle_sigterm ); 255 ::signal( SIGILL, handle_sigterm );
256 ::signal( SIGTERM, handle_sigterm );
252 ::signal ( SIGINT, handle_sigterm ); 257 ::signal ( SIGINT, handle_sigterm );
258 ::setsid();
259 ::setpgid( 0, 0 );
253 260
254 ::setsid ( ); 261 ::atexit( remove_pidfile );
255 ::setpgid ( 0, 0 ); 262 create_pidfile();
256
257 ::atexit ( remove_pidfile );
258 create_pidfile ( );
259 263
260 int retVal = initApplication( argc, argv ); 264 int retVal = initApplication( argc, argv );
261 265
262 // Have we been asked to restart? 266 // Have we been asked to restart?
263 if ( ServerApplication::doRestart ) { 267 if ( ServerApplication::doRestart )
264 for ( int fd = 3; fd < 100; fd++ ) 268 {
265 close( fd ); 269 for ( int fd = 3; fd < 100; fd++ ) close( fd );
266 270 execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 );
267 execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 );
268 }
269
270 // Kill them. Kill them all.
271 ::kill ( 0, SIGTERM );
272 ::sleep ( 1 );
273 ::kill ( 0, SIGKILL );
274
275 return retVal;
276}
277#else
278
279int main( int argc, char ** argv )
280{
281 int retVal = initApplication( argc, argv );
282
283 if ( DesktopApplication::doRestart ) {
284 odebug << "Trying to restart" << oendl;
285 execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 );
286 } 271 }
287 272
288 return retVal; 273 return retVal;
289} 274}
290
291#endif
292