| 202 | } |
| 203 | |
| 204 | [[nodiscard]] static bool CreatePidFile(const ArgsManager& args) |
| 205 | { |
| 206 | if (args.IsArgNegated("-pid")) return true; |
| 207 | |
| 208 | std::ofstream file{GetPidFile(args).std_path()}; |
| 209 | if (file) { |
| 210 | #ifdef WIN32 |
| 211 | tfm::format(file, "%d\n", GetCurrentProcessId()); |
| 212 | #else |
| 213 | tfm::format(file, "%d\n", getpid()); |
| 214 | #endif |
| 215 | g_generated_pid = true; |
| 216 | return true; |
| 217 | } else { |
| 218 | return InitError(strprintf(_("Unable to create the PID file '%s': %s"), fs::PathToString(GetPidFile(args)), SysErrorString(errno))); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | static void RemovePidFile(const ArgsManager& args) |
| 223 | { |
no test coverage detected