struct timeval fdtimeout;
- /* Going daemon */
pid = getpid();
available_server = 0;
- nowDaemon();
- goDaemon();
+
+
+ /* Going Daemon */
+ if (!run_foreground)
+ {
+ nowDaemon();
+ goDaemon();
+ }
/* Setting group ID */
* and read from it
* Exit if fails.
*/
- if((logr->m_queue = StartMQ(DEFAULTQUEUE, READ)) < 0)
+ if((agt->m_queue = StartMQ(DEFAULTQUEUE, READ)) < 0)
ErrorExit(QUEUE_ERROR, ARGV0, DEFAULTQUEUE, strerror(errno));
- maxfd = logr->m_queue;
- logr->sock = -1;
+ maxfd = agt->m_queue;
+ agt->sock = -1;
- /* Creating PID file */
+ /* Creating PID file */
if(CreatePID(ARGV0, getpid()) < 0)
merror(PID_ERROR,ARGV0);
os_write_agent_info(keys.keyentries[0]->name, NULL, keys.keyentries[0]->id);
*/
os_write_agent_info(keys.keyentries[0]->name, NULL, keys.keyentries[0]->id,
- logr->profile);
+ agt->profile);
/* Start up message */
/* Connecting UDP */
rc = 0;
- while(rc < logr->rip_id)
+ while(rc < agt->rip_id)
{
- verbose("%s: INFO: Server IP Address: %s", ARGV0, logr->rip[rc]);
+ verbose("%s: INFO: Server IP Address: %s", ARGV0, agt->rip[rc]);
rc++;
}
/* Setting max fd for select */
- if(logr->sock > maxfd)
+ if(agt->sock > maxfd)
{
- maxfd = logr->sock;
+ maxfd = agt->sock;
}
/* Connecting to the execd queue */
- if(logr->execdq == 0)
+ if(agt->execdq == 0)
{
- if((logr->execdq = StartMQ(EXECQUEUE, WRITE)) < 0)
+ if((agt->execdq = StartMQ(EXECQUEUE, WRITE)) < 0)
{
merror("%s: INFO: Unable to connect to the active response "
"queue (disabled).", ARGV0);
- logr->execdq = -1;
+ agt->execdq = -1;
}
}
{
/* Monitoring all available sockets from here */
FD_ZERO(&fdset);
- FD_SET(logr->sock, &fdset);
- FD_SET(logr->m_queue, &fdset);
+ FD_SET(agt->sock, &fdset);
+ FD_SET(agt->m_queue, &fdset);
- fdtimeout.tv_sec = 120;
+ fdtimeout.tv_sec = 1;
fdtimeout.tv_usec = 0;
+ /* Continuously send notifications */
+ run_notify();
- /* Wait for 120 seconds at a maximum for any descriptor */
+ /* Wait with a timeout for any descriptor */
rc = select(maxfd, &fdset, NULL, NULL, &fdtimeout);
if(rc == -1)
{
/* For the receiver */
- if(FD_ISSET(logr->sock, &fdset))
+ if(FD_ISSET(agt->sock, &fdset))
{
receive_msg();
}
/* For the forwarder */
- if(FD_ISSET(logr->m_queue, &fdset))
+ if(FD_ISSET(agt->m_queue, &fdset))
{
EventForward();
}