QxtDaemon Class Reference
[QxtCore module]

Qt Implementation of a Unix daemon. More...

 #include <QxtDaemon>

Inherits QObject.

Public Functions

Public Static Functions

Signals


Detailed Description

QxtDaemon will provide you with a standard UNIX daemon implementation.
after sucessful forking it will install a messageHandler which logs all qDebug/qWarning/etc... output to /var/log/mydaemon.log

example usage:

int main(int argc, char ** argv)
{
     QxtDaemon d("exampled");
     qDebug("about to fork");
     d.daemonize();
     qDebug("forked");
     d.changeUser("nobody");
     QCoreApplication app(argc,argv);
     return app.exec();
}

Member Documentation

QxtDaemon ( QString applicationName = QCoreApplication::applicationName() )

constructs a new QxtDaemon
the applicationName is used as a base for log and pid files




bool daemonize ( bool pidfile = true )

forks the current Process
you can specify weather it will write a pidfile to /var/run/mydaemon.pid or not
if you specify true (the default) QxtDaemon will also try to lock the pidfile. If it can't get a lock it will assume another daemon of the same name is already running and exit
be aware that after calling this function all file descriptors are invalid. QFile will not detect the change, you have to explicitly close all files before forking.
return true on success




bool changeUser ( QString name )

changes the current user of this process.
do this after forking to drop root rights.
returns true on success




int pid ( ) static

returns the current processId




void signal ( int )




void hangup ( )




void terminate ( )






Copyright © 2007 Qxt Foundation Trademarks
Qt Extension Library 0.5