ewmscp  ..
Classes | Typedefs | Enumerations | Functions | Variables
inotify_watch.cpp File Reference

(v0.19-24-g0617ca1 with changes)

#include <chrono>
#include <csignal>
#include <dirent.h>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <poll.h>
#include <regex>
#include <atomic>
#include <scoped.h>
#include <string.h>
#include <sys/inotify.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <syslogstream.h>
#include <throwcall.h>
#include <unistd.h>
#include <Options.h>
#include <OptionsRegex.h>
Include dependency graph for inotify_watch.cpp:

Go to the source code of this file.

Classes

class  maskName
 
class  inotify_event_wrapper
 wrapper for inotify_event with nicer interface. More...
 
class  inotify_event_copy
 smart copy class for inotify_event. More...
 
class  watchedDirType
 represents a watched directory inside a directory tree. More...
 
class  commandSender
 class used to send messages via stdout. More...
 
class  commandSender::flushDomain
 class to flush output on scope basis. More...
 

Typedefs

typedef std::chrono::system_clock clock_type
 

Enumerations

enum  watchDirectoryReturnType { watchDirectoryReturnType::vanished, watchDirectoryReturnType::islink, watchDirectoryReturnType::ignore, watchDirectoryReturnType::iswatched }
 special enum for the return values of watchDirectory. More...
 

Functions

std::ostream * errStream (nullptr)
 
watchDirectoryReturnType watchDirectory (int fd, const std::string &name, watchedDirType *parent=nullptr)
 watch a directory. More...
 
std::ostream & operator<< (std::ostream &stream, std::chrono::system_clock::time_point t)
 
static void pidFileRemover ()
 
static void sigTermHandler (int)
 
static void sigPipeHandler (int)
 
static std::atomic< bool > dumpRequested (false)
 
static void sigUsrHandler (int)
 
int main (int argc, const char *argv[])
 main inotify_watch function. More...
 

Variables

options::single< std::string > errPrefix ('\0', "errPrefix", "prefix for error messages")
 
static options::single< std::string > pidFileName ('p', "pidFile", "name of PID file")
 

Typedef Documentation

◆ clock_type

typedef std::chrono::system_clock clock_type

Definition at line 60 of file inotify_watch.cpp.

Function Documentation

◆ dumpRequested()

static std::atomic<bool> dumpRequested ( false  )
static

Referenced by main(), and sigUsrHandler().

Here is the caller graph for this function:

◆ errStream()

std::ostream* errStream ( nullptr  )

Referenced by main(), printErrors(), and watchedDirType::~watchedDirType().

Here is the caller graph for this function:

◆ operator<<()

std::ostream& operator<< ( std::ostream &  stream,
std::chrono::system_clock::time_point  t 
)

Definition at line 558 of file inotify_watch.cpp.

559  {
560  stream << std::chrono::duration_cast<std::chrono::duration<double>>(t.time_since_epoch()).count();
561  return stream;
562 }

◆ pidFileRemover()

static void pidFileRemover ( )
static

Definition at line 570 of file inotify_watch.cpp.

570  {
571  if (pidFileName != "") {
572  throwcall::good0(unlink(pidFileName.c_str()), "can't unlink pid file ", pidFileName);
573  }
574 }

References throwcall::good0(), and pidFileName.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sigPipeHandler()

static void sigPipeHandler ( int  )
static

Definition at line 578 of file inotify_watch.cpp.

578  {
579  std::exit(EXIT_FAILURE);
580 }

Referenced by main().

Here is the caller graph for this function:

◆ sigTermHandler()

static void sigTermHandler ( int  )
static

Definition at line 575 of file inotify_watch.cpp.

575  {
576  std::exit(EXIT_SUCCESS);
577 }

Referenced by main().

Here is the caller graph for this function:

◆ sigUsrHandler()

static void sigUsrHandler ( int  )
static

Definition at line 582 of file inotify_watch.cpp.

582  {
583  dumpRequested = true;
584 }

References dumpRequested().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ errPrefix

options::single<std::string> errPrefix('\0', "errPrefix", "prefix for error messages")

◆ pidFileName

options::single<std::string> pidFileName( 'p', "pidFile", "name of PID file")
static

Referenced by main(), and pidFileRemover().

dumpRequested
static std::atomic< bool > dumpRequested(false)
pidFileName
static options::single< std::string > pidFileName('p', "pidFile", "name of PID file")
throwcall::good0
void good0(T call, const Args &... args)
template function to wrap system calls that return 0 on success
Definition: throwcall.h:40