Esempio n. 1
0
int _tmain(int argc, _TCHAR* argv[])
{
	Logger* log = getLogger(NULL);
	log->info("djondbd version %s is starting up.", VERSION);
	service_startup();

	/* Auto-reset, initially non-signaled event */
    ::CreateEvent(NULL, FALSE, FALSE, NULL);

    /* Add the break handler */
    ::SetConsoleCtrlHandler(signal_handler, TRUE);

	while(true) {
		if (!service_running()) {
			break;
		}
		Thread::sleep(5000);
	}
	return 0;
}
Esempio n. 2
0
/* main program */ 
int main(){ 
	
	
	
	
	setlogmask(LOG_UPTO(LOG_INFO));
        openlog(PROG_NAME, LOG_PID | LOG_CONS | LOG_PERROR, LOG_USER);
        syslog(LOG_INFO, "Program started");
        /* 
        	Check if parent process id is set not to 1 (init). 
        	If it is we are already a child and we can go straight to 
        	the task of waiting for a connection 
        */
        if (getppid() !=  1)
        {
        	signal_init();
        	daemon_startup();
        }

        /*
        	We are in the child process portion of the program. 
        	The parent process should not have made it to here. 
        */
        
        int server_fd = service_startup(); 
        
        syslog(LOG_INFO, "Daemon running");
         
        while (TRUE)
        {
            
            int session_fd=accept(server_fd,0,0);
            handle_session(session_fd); 
            close(session_fd);
            
           /* sleep(1); */ 
        }
	
	
	
}