restart_timer.deregister(event_loop);
}
+ // Set the command to run this service (executable and arguments, nul separated). The command_parts_p
+ // vector must contain pointers to each part.
+ void set_command(std::string &&command_p, std::vector<const char *> &&command_parts_p) noexcept
+ {
+ program_name = std::move(command_p);
+ exec_arg_parts = std::move(command_parts_p);
+ }
+
+ void get_command(std::string &command_p, std::vector<const char *> &command_parts_p)
+ {
+ command_p = program_name;
+ command_parts_p = exec_arg_parts;
+ }
+
// Set the stop command and arguments (may throw std::bad_alloc)
void set_stop_command(const std::string &command,
std::list<std::pair<unsigned,unsigned>> &stop_command_offsets)
stop_arg_parts = separate_args(stop_command, stop_command_offsets);
}
+ // Set the stop command as a sequence of nul-terminated parts (arguments).
+ // command - the command and arguments, each terminated with nul ('\0')
+ // command_parts - pointers to the beginning of each command part
+ void set_stop_command(std::string &&command,
+ std::vector<const char *> &&command_parts) noexcept
+ {
+ stop_command = std::move(command);
+ stop_arg_parts = std::move(command_parts);
+ }
+
void set_env_file(const std::string &env_file_p)
{
env_file = env_file_p;
}
+ void set_env_file(std::string &&env_file_p) noexcept
+ {
+ env_file = std::move(env_file_p);
+ }
+
void set_rlimits(std::vector<service_rlimits> &&rlimits_p)
{
rlimits = std::move(rlimits_p);
working_dir = working_dir_p;
}
+ void set_working_dir(string &&working_dir_p) noexcept
+ {
+ working_dir = std::move(working_dir_p);
+ }
+
// Set the notification fd number that the service process will use
void set_notification_fd(int fd)
{
strncpy(inittab_line, line, sizeof(inittab_line));
}
+ // Get the utmp (inittab) id, may not be nul terminated if maximum length!
+ const char *get_utmp_id()
+ {
+ return inittab_id;
+ }
+
+ // Get the utmp (inittab) line, may not be nul terminated if maximum length!
+ const char *get_utmp_line()
+ {
+ return inittab_line;
+ }
+
+ constexpr size_t get_utmp_id_size() const { return sizeof(inittab_id); }
+ constexpr size_t get_utmp_line_size() const { return sizeof(inittab_line); }
+
#endif
~process_service() noexcept
TERMINATED // read pid successfully, but the process already terminated
};
- // Read the pid-file, return false on failure
+ string pid_file;
+
+ // Read the pid-file contents
pid_result_t read_pid_file(bp_sys::exit_status *exit_status) noexcept;
public:
~bgproc_service() noexcept
{
}
+
+ void set_pid_file(string &&pid_file) noexcept
+ {
+ this->pid_file = std::move(pid_file);
+ }
+
+ const std::string &get_pid_file() noexcept
+ {
+ return pid_file;
+ }
};
// Service which is started and stopped via separate commands