author | zecke <zecke> | 2004-09-26 14:15:24 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-26 14:15:24 (UTC) |
commit | 31c049a24effde037c20ed9446d2725f3cb718c3 (patch) (unidiff) | |
tree | 3f33fd5ef8ceb057a1066c4f1a09ff5869bde3f4 | |
parent | 77441b90e9b5a4a23b080e7ac53a512abe96f8a9 (diff) | |
download | opie-31c049a24effde037c20ed9446d2725f3cb718c3.zip opie-31c049a24effde037c20ed9446d2725f3cb718c3.tar.gz opie-31c049a24effde037c20ed9446d2725f3cb718c3.tar.bz2 |
Since some 2.6.8 kernel the Linux kernel one can set
the process name with prctl. Let us use this as well
-rw-r--r-- | core/tools/quicklauncher/main.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/tools/quicklauncher/main.cpp b/core/tools/quicklauncher/main.cpp index fb2ca44..286aed2 100644 --- a/core/tools/quicklauncher/main.cpp +++ b/core/tools/quicklauncher/main.cpp | |||
@@ -23,48 +23,56 @@ | |||
23 | 23 | ||
24 | /* OPIE */ | 24 | /* OPIE */ |
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
27 | 27 | ||
28 | /* QT */ | 28 | /* QT */ |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qstrlist.h> | 30 | #include <qstrlist.h> |
31 | #include <qtimer.h> | 31 | #include <qtimer.h> |
32 | #include <qguardedptr.h> | 32 | #include <qguardedptr.h> |
33 | #include <qcopchannel_qws.h> | 33 | #include <qcopchannel_qws.h> |
34 | 34 | ||
35 | #ifdef private | 35 | #ifdef private |
36 | # undef private | 36 | # undef private |
37 | #endif | 37 | #endif |
38 | #define private public | 38 | #define private public |
39 | #include <qtopia/qpeapplication.h> | 39 | #include <qtopia/qpeapplication.h> |
40 | #undef private | 40 | #undef private |
41 | 41 | ||
42 | /* STD */ | 42 | /* STD */ |
43 | #include <stdio.h> | 43 | #include <stdio.h> |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
46 | #include <sys/stat.h> | 46 | #include <sys/stat.h> |
47 | |||
48 | #ifdef _OS_LINUX_ | ||
49 | #include <sys/prctl.h> | ||
50 | #ifndef PR_SET_NAME | ||
51 | #define PR_SET_NAME 15 | ||
52 | #endif | ||
53 | #endif | ||
54 | |||
47 | #include <unistd.h> | 55 | #include <unistd.h> |
48 | 56 | ||
49 | 57 | ||
50 | using QuickPrivate::PluginLoader; | 58 | using QuickPrivate::PluginLoader; |
51 | 59 | ||
52 | static QPEApplication *app = 0; | 60 | static QPEApplication *app = 0; |
53 | static PluginLoader *loader = 0; | 61 | static PluginLoader *loader = 0; |
54 | static ApplicationInterface *appIface = 0; | 62 | static ApplicationInterface *appIface = 0; |
55 | static QGuardedPtr<QWidget> mainWindow; | 63 | static QGuardedPtr<QWidget> mainWindow; |
56 | 64 | ||
57 | #ifdef _OS_LINUX_ | 65 | #ifdef _OS_LINUX_ |
58 | static char **argv0 = 0; | 66 | static char **argv0 = 0; |
59 | static int argv_lth; | 67 | static int argv_lth; |
60 | extern char **environ; | 68 | extern char **environ; |
61 | #ifndef SPT_BUFSIZE | 69 | #ifndef SPT_BUFSIZE |
62 | #define SPT_BUFSIZE 2048 | 70 | #define SPT_BUFSIZE 2048 |
63 | #endif | 71 | #endif |
64 | #include <stdarg.h> | 72 | #include <stdarg.h> |
65 | void setproctitle (const char *fmt,...) { | 73 | void setproctitle (const char *fmt,...) { |
66 | int i; | 74 | int i; |
67 | char buf[SPT_BUFSIZE]; | 75 | char buf[SPT_BUFSIZE]; |
68 | va_list ap; | 76 | va_list ap; |
69 | 77 | ||
70 | if (!argv0) | 78 | if (!argv0) |
@@ -145,48 +153,49 @@ private slots: | |||
145 | stream >> arg; | 153 | stream >> arg; |
146 | odebug << "QuickLauncher execute: " << arg << oendl; | 154 | odebug << "QuickLauncher execute: " << arg << oendl; |
147 | QStrList argList; | 155 | QStrList argList; |
148 | argList.append( arg.utf8() ); | 156 | argList.append( arg.utf8() ); |
149 | doQuickLaunch( argList ); | 157 | doQuickLaunch( argList ); |
150 | delete this; | 158 | delete this; |
151 | } | 159 | } |
152 | } | 160 | } |
153 | 161 | ||
154 | private: | 162 | private: |
155 | void doQuickLaunch( QStrList &argList ) | 163 | void doQuickLaunch( QStrList &argList ) |
156 | { | 164 | { |
157 | static int myargc = argList.count(); | 165 | static int myargc = argList.count(); |
158 | static char **myargv = new char *[myargc + 1]; | 166 | static char **myargv = new char *[myargc + 1]; |
159 | 167 | ||
160 | for ( int j = 0; j < myargc; j++ ) { | 168 | for ( int j = 0; j < myargc; j++ ) { |
161 | myargv[j] = new char [strlen(argList.at(j))+1]; | 169 | myargv[j] = new char [strlen(argList.at(j))+1]; |
162 | strcpy( myargv[j], argList.at(j) ); | 170 | strcpy( myargv[j], argList.at(j) ); |
163 | } | 171 | } |
164 | 172 | ||
165 | myargv[myargc] = NULL; | 173 | myargv[myargc] = NULL; |
166 | #ifdef _OS_LINUX_ | 174 | #ifdef _OS_LINUX_ |
167 | // Change name of process | 175 | // Change name of process |
168 | setproctitle(myargv[0]); | 176 | setproctitle(myargv[0]); |
177 | prctl( PR_SET_NAME, (unsigned long)myargv[0], 0, 0, 0 ); | ||
169 | #endif | 178 | #endif |
170 | 179 | ||
171 | connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); | 180 | connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); |
172 | app->exit_loop(); | 181 | app->exit_loop(); |
173 | app->initApp( myargc, myargv ); | 182 | app->initApp( myargc, myargv ); |
174 | exec( myargc, myargv ); | 183 | exec( myargc, myargv ); |
175 | } | 184 | } |
176 | 185 | ||
177 | private: | 186 | private: |
178 | QCopChannel *qlChannel; | 187 | QCopChannel *qlChannel; |
179 | }; | 188 | }; |
180 | 189 | ||
181 | int main( int argc, char** argv ) | 190 | int main( int argc, char** argv ) |
182 | { | 191 | { |
183 | app = new QPEApplication( argc, argv ); | 192 | app = new QPEApplication( argc, argv ); |
184 | 193 | ||
185 | loader = new PluginLoader( "application" ); | 194 | loader = new PluginLoader( "application" ); |
186 | 195 | ||
187 | unsetenv( "LD_BIND_NOW" ); | 196 | unsetenv( "LD_BIND_NOW" ); |
188 | 197 | ||
189 | QCString arg0 = argv[0]; | 198 | QCString arg0 = argv[0]; |
190 | int sep = arg0.findRev( '/' ); | 199 | int sep = arg0.findRev( '/' ); |
191 | 200 | ||
192 | if ( sep > 0 ) | 201 | if ( sep > 0 ) |