FreeBSD/contrib/openbsm/bin/auditd/auditd_fbsd.c
/* 
 * The main event loop.  Wait for trigger messages or signals and handle them.
 * It should not return unless there is a problem.
 */
The main event loop.  Wait for trigger messages or signals and handle them.
It should not return unless there is a problem.
The main event loop . Wait for trigger messages or signals and handle them . It should not return unless there is a problem .
void
auditd_wait_for_events(void)
{
	int num;
	unsigned int trigger;
	for (;;) {
		num = read(triggerfd, &trigger, sizeof(trigger));
		if ((num == -1) && (errno != EINTR)) {
			auditd_log_err("%s: error %d", __FUNCTION__, errno);
			return;
		}
		if (max_idletime)
			alarm(max_idletime);
		if (sigterms != sigterms_handled) {
			auditd_log_debug("%s: SIGTERM", __FUNCTION__);
			auditd_terminate();
		}
		if (sigalrms != sigalrms_handled) {
			auditd_log_debug("%s: SIGALRM", __FUNCTION__);
			auditd_terminate();
		}
 		if (sigchlds != sigchlds_handled) {
			sigchlds_handled = sigchlds;
			auditd_reap_children();
		}
		if (sighups != sighups_handled) {
			auditd_log_debug("%s: SIGHUP", __FUNCTION__);
			sighups_handled = sighups;
			auditd_config_controls();
		}
		if ((num == -1) && (errno == EINTR))
			continue;
		if (num == 0) {
			auditd_log_err("%s: read EOF", __FUNCTION__);
			return;
		}
		auditd_handle_trigger(trigger);
	}
}
void auditd_wait_for_events ( void ) { int num ; unsigned int trigger ; for ( ; ; ) { num = read ( triggerfd , & trigger , sizeof ( trigger ) ) ; if ( ( num == -1 ) && ( errno != EINTR ) ) { auditd_log_err ( " " , __FUNCTION__ , errno ) ; return ; } if ( max_idletime ) alarm ( max_idletime ) ; if ( sigterms != sigterms_handled ) { auditd_log_debug ( " " , __FUNCTION__ ) ; auditd_terminate ( ) ; } if ( sigalrms != sigalrms_handled ) { auditd_log_debug ( " " , __FUNCTION__ ) ; auditd_terminate ( ) ; } if ( sigchlds != sigchlds_handled ) { sigchlds_handled = sigchlds ; auditd_reap_children ( ) ; } if ( sighups != sighups_handled ) { auditd_log_debug ( " " , __FUNCTION__ ) ; sighups_handled = sighups ; auditd_config_controls ( ) ; } if ( ( num == -1 ) && ( errno == EINTR ) ) continue ; if ( num == 0 ) { auditd_log_err ( " " , __FUNCTION__ ) ; return ; } auditd_handle_trigger ( trigger ) ; } }
The main event loop.
The main event loop .
/* Reset the idle time alarm, if used. */ /* not reached */ /* not reached */