summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -68,3 +68,3 @@ static void cleanup()
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 }
@@ -89,3 +89,3 @@ void initEnvironment()
89 if (tz.isNull() || tz.isEmpty()) 89 if (tz.isNull() || tz.isEmpty())
90 tz = "America/New_York"; 90 tz = "America/New_York";
91 91
@@ -97,3 +97,3 @@ void initEnvironment()
97 if( lang.isNull() || lang.isEmpty()) 97 if( lang.isNull() || lang.isEmpty())
98 lang = "en_US"; 98 lang = "en_US";
99 99
@@ -127,3 +127,3 @@ static void initKeyboard()
127 if ( ard > 0 && arp > 0 ) 127 if ( ard > 0 && arp > 0 )
128 qwsSetKeyboardAutoRepeat( ard, arp ); 128 qwsSetKeyboardAutoRepeat( ard, arp );
129 129
@@ -143,5 +143,5 @@ static bool firstUse()
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 }
@@ -149,3 +149,3 @@ static bool firstUse()
149 if ( !needFirstUse ) 149 if ( !needFirstUse )
150 return FALSE; 150 return FALSE;
151 151
@@ -177,4 +177,4 @@ int initApplication( int argc, char ** argv )
177 if ( firstUse() ) { 177 if ( firstUse() ) {
178 a.restart(); 178 a.restart();
179 return 0; 179 return 0;
180 } 180 }
@@ -185,3 +185,3 @@ int initApplication( int argc, char ** argv )
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 }
@@ -225,8 +225,8 @@ void 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}
@@ -235,3 +235,3 @@ void remove_pidfile ( )
235{ 235{
236 ::unlink ( pidfile_path ); 236 ::unlink ( pidfile_path );
237} 237}
@@ -240,20 +240,24 @@ void 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
@@ -262,25 +266,6 @@ int main( int argc, char ** argv )
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 }
@@ -289,4 +274 @@ int main( int argc, char ** argv )
289} 274}
290
291#endif
292