-rw-r--r-- | core/launcher/main.cpp | 92 |
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 | |||
@@ -67,5 +67,5 @@ static void cleanup() | |||
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 | } |
@@ -88,5 +88,5 @@ void initEnvironment() | |||
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 ); |
@@ -96,5 +96,5 @@ void initEnvironment() | |||
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 ); |
@@ -126,5 +126,5 @@ static void initKeyboard() | |||
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" ); |
@@ -142,11 +142,11 @@ static bool firstUse() | |||
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(); |
@@ -176,6 +176,6 @@ int initApplication( int argc, char ** argv ) | |||
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 | ||
@@ -184,5 +184,5 @@ int initApplication( int argc, char ** argv ) | |||
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 | ||
@@ -224,69 +224,51 @@ static const char *pidfile_path = "/var/run/opie.pid"; | |||
224 | void create_pidfile ( ) | 224 | 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 | } |
233 | 233 | ||
234 | void remove_pidfile ( ) | 234 | void remove_pidfile ( ) |
235 | { | 235 | { |
236 | ::unlink ( pidfile_path ); | 236 | ::unlink ( pidfile_path ); |
237 | } | 237 | } |
238 | 238 | ||
239 | void handle_sigterm ( int /* sig */ ) | 239 | 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 | ||
246 | int main( int argc, char ** argv ) | 250 | int 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 | |||
279 | int 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 | |||