Class forkable
Defined in File forkable.hpp
Class Documentation
-
class forkable
Daemon interface class which can be derived from to indicate that the class can be fork()ed and having each new process jump into the main loop defined for the class.
Public Functions
-
forkable(void) = default
-
virtual ~forkable(void) = default
-
inline pid_t pid(void) const
-
virtual void proc_main(void) = 0
Entry point for the new process.
-
pid_t start(const std::string &new_wd, int core = -1)
Start a process in a new directory.
- Parameters:
new_wd – The new working directory to start the process in.
core – The core to bind the process (and any threads it might spawn) to. By default, no binding.
- Returns:
PID of child process in parent, or -1 if chdir() failed with
new_wd
.
-
pid_t start(int core = -1)
Start a process.
- Parameters:
core – The core to bind the process (and any threads it might spawn) to. By default, no binding.
- Returns:
PID of child process in parent.
-
inline virtual void term(void)
Signal a process that it should terminate, from outside the process.
Protected Functions
-
inline bool terminated(void) const
Check if a process object has been told to terminate elsewhere.
-
forkable(void) = default