incron
0.5.10
|
inotify cron daemon main file More...
#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 <cstdio>
#include <cstring>
#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 |
#define | POLL_EAGAIN_WAIT 3 |
Second to wait on EAGAIN. | |
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) |
Checks whether a parameter string is a specific command. | |
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 daemon main file
inotify cron system
Copyright (C) 2006, 2007, 2008, 2012 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).
Credits: Christian Ruppert (new include to build with GCC 4.4+)
#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 |
"incrond - inotify cron daemon\n" \ "(c) Lukas Jelinek, 2006, 2007, 2008"
incrontab description string
#define INCROND_HELP |
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"
incrontab help string
#define INCROND_VERSION INCROND_NAME " " INCRON_VERSION |
incrond version string
#define POLL_EAGAIN_WAIT 3 |
Second to wait on EAGAIN.
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 | ||
) |
Checks whether a parameter string is a specific command.
The string is accepted if it equals either the short or long form of the command.
[in] | s | checked string |
[in] | shortCmd | short form of command |
[in] | longCmd | long form of command |
[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.