3 # Patch managed by http://www.holgerschurig.de/patcher.html
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
14 #if defined(_OS_AIX_) && defined(_CC_GNU_)
15 #include <sys/select.h>
17 //these used to be environment variables, they are initialized from
18 //environment variables in
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 @@
26 } else if ( arg == "-shared" ) {
27 qws_shared_memory = TRUE;
28 + } else if ( arg == "-daemon" ) {
30 + } else if ( arg == "-nodaemon" ) {
32 } else if ( arg == "-noshared" ) {
33 qws_shared_memory = FALSE;
34 } else if ( arg == "-savefonts" ) {
35 @@ -1742,6 +1748,78 @@
37 qws_single_process = TRUE;
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.
47 + qWarning( "qt_init() - starting in daemon mode..." );
52 + qWarning( "qt_init() - can't perform initial fork: %s", strerror( errno ) );
55 + if ( pid1 ) _exit( 0 ); // ok, first fork performed
64 + int fdnull = ::open( "/dev/null", O_RDWR );
67 + syslog( 3, "qt_init() - can't open /dev/null to redirect std{in|out|err}: %s", strerror( errno ) );
70 + dup2( fdnull, 0 ); // stdin
71 + dup2( fdnull, 1 ); // stdout
72 + dup2( fdnull, 2 ); // stderr
77 + syslog( 3, "qt_init() - can't perform initial fork: %s", strerror( errno ) );
82 + syslog( 4, "qt_init() [%d] - successfully entered daemon mode", pid2 );
83 + _exit( 0 ); // ok, second fork performed
90 + * \ \___ / | B E W A R E !
91 + * /- _ `-/ ' We are a DAEMON now!
100 + * <----|====O)))==) \) /====
101 + * <----' `--' `.__,' \
104 + * ______( (_ / \______
105 + * (FL) ,' ,-----' | \
106 + * `--{__________) \/
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.