Diffstat (limited to 'qt/qt-2.3.7.patch/qte237-1-daemon.patch') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qt/qt-2.3.7.patch/qte237-1-daemon.patch | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/qt/qt-2.3.7.patch/qte237-1-daemon.patch b/qt/qt-2.3.7.patch/qte237-1-daemon.patch new file mode 100644 index 0000000..1f83398 --- a/dev/null +++ b/qt/qt-2.3.7.patch/qte237-1-daemon.patch | |||
@@ -0,0 +1,113 @@ | |||
1 | |||
2 | # | ||
3 | # Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher | ||
4 | # | ||
5 | |||
6 | --- qt-2.3.7/src/kernel/qapplication_qws.cpp~daemonize2004-07-17 22:47:54.840820000 +0200 | ||
7 | +++ qt-2.3.7/src/kernel/qapplication_qws.cpp2004-07-17 23:34:32.407525912 +0200 | ||
8 | @@ -103,6 +103,7 @@ | ||
9 | #endif | ||
10 | |||
11 | #include <sys/time.h> | ||
12 | +#include <syslog.h> | ||
13 | |||
14 | #if defined(_OS_AIX_) && defined(_CC_GNU_) | ||
15 | #include <sys/select.h> | ||
16 | @@ -162,6 +163,7 @@ | ||
17 | //these used to be environment variables, they are initialized from | ||
18 | //environment variables in | ||
19 | |||
20 | +bool qws_daemon = TRUE; | ||
21 | bool qws_savefonts = FALSE; | ||
22 | bool qws_screen_is_interlaced=FALSE; //### should be detected | ||
23 | bool qws_shared_memory = FALSE; | ||
24 | @@ -1614,6 +1616,10 @@ | ||
25 | mwGeometry = argv[i]; | ||
26 | } else if ( arg == "-shared" ) { | ||
27 | qws_shared_memory = TRUE; | ||
28 | +} else if ( arg == "-daemon" ) { | ||
29 | + qws_daemon = TRUE; | ||
30 | +} else if ( arg == "-nodaemon" ) { | ||
31 | + qws_daemon = FALSE; | ||
32 | } else if ( arg == "-noshared" ) { | ||
33 | qws_shared_memory = FALSE; | ||
34 | } else if ( arg == "-savefonts" ) { | ||
35 | @@ -1670,6 +1676,78 @@ | ||
36 | qt_appType = type; | ||
37 | qws_single_process = TRUE; | ||
38 | |||
39 | + /* Daemonize the server process -- (C) Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
40 | + * Added a new command line option which only is relevant if the application is created as a GuiServer. | ||
41 | + * The option is -daemon respectively -nodaemon. If in daemon mode (which is the default now), the | ||
42 | + * server will detach from the controlling terminal and continue as a daemon. This is done via the standard | ||
43 | + * UNIX double fork magic. | ||
44 | + */ | ||
45 | + if ( qws_daemon ) | ||
46 | + { | ||
47 | + qWarning( "qt_init() - starting in daemon mode..." ); | ||
48 | + | ||
49 | + int pid1 = fork(); | ||
50 | + if ( pid1 == -1 ) | ||
51 | + { | ||
52 | + qWarning( "qt_init() - can't perform initial fork: %s", strerror( errno ) ); | ||
53 | + exit( -1 ); | ||
54 | + } | ||
55 | + if ( pid1 ) _exit( 0 ); // ok, first fork performed | ||
56 | + | ||
57 | + chdir( "/" ); | ||
58 | + setsid(); | ||
59 | + umask(0); | ||
60 | + close(0); | ||
61 | + close(1); | ||
62 | + close(2); | ||
63 | + | ||
64 | + int fdnull = ::open( "/dev/null", O_RDWR ); | ||
65 | + if ( fdnull == -1 ) | ||
66 | + { | ||
67 | + syslog( 3, "qt_init() - can't open /dev/null to redirect std{in|out|err}: %s", strerror( errno ) ); | ||
68 | + exit( -1 ); | ||
69 | + } | ||
70 | + dup2( fdnull, 0 ); // stdin | ||
71 | + dup2( fdnull, 1 ); // stdout | ||
72 | + dup2( fdnull, 2 ); // stderr | ||
73 | + | ||
74 | + int pid2 = fork(); | ||
75 | + if ( pid2 == -1 ) | ||
76 | + { | ||
77 | + syslog( 3, "qt_init() - can't perform initial fork: %s", strerror( errno ) ); | ||
78 | + exit( -1 ); | ||
79 | + } | ||
80 | + if ( pid2 ) | ||
81 | + { | ||
82 | + syslog( 4, "qt_init() [%d] - successfully entered daemon mode", pid2 ); | ||
83 | + _exit( 0 ); // ok, second fork performed | ||
84 | + } | ||
85 | + } | ||
86 | + | ||
87 | + /* | ||
88 | + * , , | ||
89 | + * /( )` | ||
90 | + * \ \___ / | B E W A R E ! | ||
91 | + * /- _ `-/ ' We are a DAEMON now! | ||
92 | + * (/\/ \ \ /\ | ||
93 | + * / / | ` \ | ||
94 | + * O O ) / | | ||
95 | + * `-^--'`< ' | ||
96 | + * (_.) _ ) / | ||
97 | + * `.___/` / | ||
98 | + * `-----' / | ||
99 | + * <----. __ / __ \ | ||
100 | + * <----|====O)))==) \) /==== | ||
101 | + * <----' `--' `.__,' \ | ||
102 | + * | | | ||
103 | + * \ / | ||
104 | + * ______( (_ / \______ | ||
105 | + * (FL) ,' ,-----' | \ | ||
106 | + * `--{__________) \/ | ||
107 | + * | ||
108 | + */ | ||
109 | + | ||
110 | + | ||
111 | /* Allocate a dedicated virtual terminal -- (C) Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
112 | * Added a new command line option which only is relevant if the application is created as a GuiServer. | ||
113 | * The option is -terminal <num>, where <num> specifies the virtual terminal to be occupied by the server. | ||