summaryrefslogtreecommitdiff
path: root/qt/qt-2.3.10.patch/daemonize.patch
Unidiff
Diffstat (limited to 'qt/qt-2.3.10.patch/daemonize.patch') (more/less context) (ignore whitespace changes)
-rw-r--r--qt/qt-2.3.10.patch/daemonize.patch113
1 files changed, 113 insertions, 0 deletions
diff --git a/qt/qt-2.3.10.patch/daemonize.patch b/qt/qt-2.3.10.patch/daemonize.patch
new file mode 100644
index 0000000..487a18c
--- a/dev/null
+++ b/qt/qt-2.3.10.patch/daemonize.patch
@@ -0,0 +1,113 @@
1
2#
3# Patch managed by http://www.holgerschurig.de/patcher.html
4#
5
6--- qt-2.3.9-snapshot-20041211/src/kernel/qapplication_qws.cpp~daemonize
7+++ qt-2.3.9-snapshot-20041211/src/kernel/qapplication_qws.cpp
8@@ -104,6 +104,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@@ -163,6 +164,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@@ -1686,6 +1688,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@@ -1742,6 +1748,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.