I am sorry, this may be a stupid question.
I am trying to make a very simple application become a daemon but it seems I can't work it out. I tried to "ps-ef" the application but it returns nothing.
The "daemonizing" code is below.
when I try to run the program, it results to this :Code:// App.c #include <stdio.h> int daemon_init(const char * parAppName){ int iCounter; int iPid; char *pTmp; // if the fork() call fails, this service won't be started if( (iPid = fork()) != 0 ){ printf("%s Daemonizing failed 1... \n", parAppName); exit(0); } // set session id setsid(); //signal( SIGHUP, SIG_IGN); // if the fork() call fails, this service won't be started if( (iPid = fork()) !=0 ){ printf("%s Daemonizing failed 2... \n", parAppName); exit(0); } chdir("/"); umask(0); printf("%s Daemonizing Complete... \n", parAppName); return 0; } int main( int argc, char * argv[] ){ daemon_init(argv[0]); return 0; }
App Daemonizing Complete...
App Daemonizing failed 2...
App Daemonizing failed 1...



LinkBack URL
About LinkBacks



