icd-main.cpp(3)

NAME
icd-main.cpp -

inotify cron daemon main file

SYNOPSIS

#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'.

Detailed Description

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 Documentation

  #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:

incrontab description string

  #define INCROND_HELP Value:

INCROND_DESCRIPTION 'n'           'usage: incrond [<options>]n'           '<operation> may be one of the following:           'These options may be used:           '  -?, --about                  gives short information about program           '  -h, --help                   prints this help text           '  -n, --foreground             runs on foreground (no daemonizing)           '  -k, --kill                   terminates running instance of incrond           '  -f <FILE>, --config=<FILE>   overrides default configuration file  (requires root privileges)           '  -V, --version                prints program versionn'           'For reporting bugs please use http://bts.aiken.cz

incrontab help string

  #define INCROND_VERSION INCROND_NAME ' ' INCRON_VERSION

incrond version string

  #define POLL_EAGAIN_WAIT 3

Second to wait on EAGAIN'.

Function Documentation

  void free_tables (EventDispatcher *pEd)

Deallocates all memory used by incron tables and unregisters them from the dispatcher'. Parameters:
    pEd event dispatcher

  void init_poll_array (struct pollfdpfd[], intpipefd, intinfd)

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'.

Parameters:
    s checked string
    shortCmd short form of command
    longCmd long form of command

Returns:
    true = string accepted, false = otherwise Initializes a poll array'.

Parameters:
    pfd poll structure array
    pipefd pipe file descriptor
    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'.

Parameters:
    pEd inotify event dispatcher

Exceptions:
    InotifyException thrown if base table directory cannot be read

  int main (intargc, char **argv)

Main application function'. Parameters:
    argc argument count
    argv argument array

Returns:
    0 on success, 1 on error

Attention:
    In daemon mode, it finishes immediately'.

  void on_signal (intsigno)

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)'.

Parameters:
    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'.

Variable Documentation

  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'.

  SUT_MAP g_ut

User name to user table mapping table'.

Author

Generated automatically by Doxygen for incron from the source code'.