diff options
author | jjl | 2010-09-21 23:43:32 +0200 |
---|---|---|
committer | jjl | 2010-09-21 23:43:32 +0200 |
commit | b6e32a987be01ccd0331dc1f75b55c7095cb4011 (patch) | |
tree | 76503734d369e3c2572597cf6c3decd8130c86d3 /src/pvsDaemon.cpp | |
parent | All printf() replaced with qDebug() (diff) | |
download | pvs-b6e32a987be01ccd0331dc1f75b55c7095cb4011.tar.gz pvs-b6e32a987be01ccd0331dc1f75b55c7095cb4011.tar.xz pvs-b6e32a987be01ccd0331dc1f75b55c7095cb4011.zip |
pvsgui autostart
Diffstat (limited to 'src/pvsDaemon.cpp')
-rw-r--r--[-rwxr-xr-x] | src/pvsDaemon.cpp | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/src/pvsDaemon.cpp b/src/pvsDaemon.cpp index cc11bd4..c975a9e 100755..100644 --- a/src/pvsDaemon.cpp +++ b/src/pvsDaemon.cpp @@ -61,7 +61,7 @@ void printCommands() /// int main(int argc, char** argv) { - bool daemon = false; + bool _daemon = false; int frequency = 5; int port = -1; @@ -141,7 +141,7 @@ int main(int argc, char** argv) printVersion(true); break; case 'd': - daemon = true; + _daemon = true; break; case 'c': { @@ -250,38 +250,10 @@ int main(int argc, char** argv) ConsoleLog setLogName(QString("log.client")); ConsoleLog writeLine(QString("PVS-Client started.")); - if (daemon) + if (_daemon) { #ifndef __WIN32__ - pid_t pid, sid; // our process ID and session ID - - // fork off the parent process - pid = fork(); - if (pid < 0) - exit(-1); - - // if we got a good PID, then we can exit the parent process. - if (pid > 0) - exit(0); - - // change the file mode mask - umask(0); - - // create a new SID for the child process - sid = setsid(); - if (sid < 0) - exit(-1); - - // change the current working directory - if ((chdir("/")) < 0) - exit(-1); - - // close out the standard file descriptors - close(STDIN_FILENO); - freopen ((QString(getHomeDir()).append(QString("/.pvs/dump"))).toUtf8() - .data(),"w",stdout); - //close(STDOUT_FILENO); - close(STDERR_FILENO); + daemon(1, 1); #endif /*__WIN32__*/ } |