waiting_for_deps = false;
- if (has_console) log_to_console = false;
-
if (service_type == ServiceType::PROCESS || service_type == ServiceType::BGPROCESS
|| service_type == ServiceType::SCRIPTED) {
bool start_success = start_ps_process();
releaseConsole();
}
else if (startCheckDependencies(false)) {
+ log_to_console = false;
allDepsStarted(true);
}
else {
const char *pid_file_c = pid_file.c_str();
int fd = open(pid_file_c, O_CLOEXEC);
if (fd != -1) {
- char pidbuf[10];
- int r = read(fd, pidbuf, 9);
+ char pidbuf[21]; // just enought to hold any 64-bit integer
+ int r = read(fd, pidbuf, 20);
if (r > 0) {
pidbuf[r] = 0; // store nul terminator
pid = std::atoi(pidbuf);
ev_child_start(ev_default_loop(EVFLAG_AUTO), &child_listener);
}
else {
+ log(LogLevel::ERROR, service_name, ": pid read from pidfile (", pid, ") is not valid");
pid = -1;
+ failed_to_start();
+ close(fd);
+ return;
}
}
close(fd);