#include <map>
#include <signal.h>
#include <wait.h>
#include <fcntl.h>
#include <pwd.h>
#include <dirent.h>
#include <syslog.h>
#include <errno.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include "inotify-cxx.h"
#include "appinst.h"
#include "appargs.h"
#include "incron.h"
#include "incrontab.h"
#include "usertable.h"
#include "incroncfg.h"
Defines | |
#define | INCRON_LOG_OPTS (LOG_CONS | LOG_PID) |
Logging options (console as fallback, log PID). | |
#define | INCRON_LOG_FACIL LOG_CRON |
Logging facility (use CRON). | |
#define | INCROND_VERSION INCROND_NAME " " INCRON_VERSION |
incrond version string | |
#define | INCROND_DESCRIPTION |
incrontab description string | |
#define | INCROND_HELP |
incrontab help string | |
#define | CHILD_PIPE_BUF_LEN 32 |
Functions | |
void | on_signal (int signo) |
Handles a signal. | |
void | load_tables (EventDispatcher *pEd) throw (InotifyException) |
Attempts to load all (user and system) incron tables. | |
void | free_tables (EventDispatcher *pEd) |
Deallocates all memory used by incron tables and unregisters them from the dispatcher. | |
void | prepare_pipe () |
Prepares a 'dead/done child' notification pipe. | |
void | init_poll_array (struct pollfd pfd[], int pipefd, int infd) |
Initializes a poll array. | |
int | main (int argc, char **argv) |
Main application function. | |
Variables | |
SUT_MAP | g_ut |
User name to user table mapping table. | |
volatile bool | g_fFinish = false |
Finish program yes/no. | |
int | g_cldPipe [2] |
Pipe for notifying about dead children. | |
char | g_cldPipeBuf [CHILD_PIPE_BUF_LEN] |
bool | g_daemon = true |
Daemonize true/false. |
inotify cron system
Copyright (C) 2006, 2007 Lukas Jelinek, <lukas@aiken.cz>
This program is free software; you can use it, redistribute it and/or modify it under the terms of the GNU General Public License, version 2 (see LICENSE-GPL).
#define CHILD_PIPE_BUF_LEN 32 |
#define INCRON_LOG_FACIL LOG_CRON |
Logging facility (use CRON).
#define INCRON_LOG_OPTS (LOG_CONS | LOG_PID) |
Logging options (console as fallback, log PID).
#define INCROND_DESCRIPTION |
Value:
"incrond - inotify cron daemon\n" \ "(c) Lukas Jelinek, 2006, 2007"
#define INCROND_HELP |
Value:
INCROND_DESCRIPTION "\n\n" \ "usage: incrond [<options>]\n\n" \ "<operation> may be one of the following:\n" \ "These options may be used:\n" \ " -?, --about gives short information about program\n" \ " -h, --help prints this help text\n" \ " -n, --foreground runs on foreground (no daemonizing)\n" \ " -k, --kill terminates running instance of incrond\n" \ " -f <FILE>, --config=<FILE> overrides default configuration file (requires root privileges)\n" \ " -V, --version prints program version\n\n" \ "For reporting bugs please use http:://bts.aiken.cz\n"
#define INCROND_VERSION INCROND_NAME " " INCRON_VERSION |
incrond version string
void free_tables | ( | EventDispatcher * | pEd | ) |
Deallocates all memory used by incron tables and unregisters them from the dispatcher.
[in] | pEd | event dispatcher |
void init_poll_array | ( | struct pollfd | pfd[], | |
int | pipefd, | |||
int | infd | |||
) |
Initializes a poll array.
[out] | pfd | poll structure array |
[in] | pipefd | pipe file descriptor |
[in] | infd | inotify infrastructure file descriptor |
void load_tables | ( | EventDispatcher * | pEd | ) | throw (InotifyException) |
Attempts to load all (user and system) incron tables.
Loaded tables are registered for processing events.
[in] | pEd | inotify event dispatcher |
InotifyException | thrown if base table directory cannot be read |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Main application function.
[in] | argc | argument count |
[in] | argv | argument array |
void on_signal | ( | int | signo | ) |
Handles a signal.
For SIGTERM and SIGINT it sets the program finish variable. For SIGCHLD it writes a character into the notification pipe (this is a workaround made due to disability to reliably wait for dead children).
[in] | signo | signal number |
void prepare_pipe | ( | ) |
Prepares a 'dead/done child' notification pipe.
This function returns no value at all and on error it throws an exception.
int g_cldPipe[2] |
Pipe for notifying about dead children.
char g_cldPipeBuf[CHILD_PIPE_BUF_LEN] |
bool g_daemon = true |
Daemonize true/false.
volatile bool g_fFinish = false |
Finish program yes/no.