20 #ifndef MPD_PID_FILE_HXX
21 #define MPD_PID_FILE_HXX
41 fd =
OpenFile(path, O_WRONLY|O_CREAT|O_TRUNC, 0666);
43 const std::string utf8 = path.
ToUTF8();
75 sprintf(buffer,
"%lu\n", (
unsigned long)pid);
77 write(fd, buffer, strlen(buffer));
93 int fd =
OpenFile(path, O_RDONLY, 0);
100 auto nbytes = read(fd, buffer,
sizeof(buffer) - 1);
105 auto value = strtoul(buffer, &endptr, 10);
static gcc_pure pid_t ReadPidFile(Path path)
PidFile(const AllocatedPath &path)
A path name in the native file system character set.
gcc_pure std::string ToUTF8() const
Convert the path to UTF-8.
void Delete(const AllocatedPath &path)
A path name in the native file system character set.
gcc_noreturn void FormatFatalSystemError(const char *fmt,...)
gcc_pure const_pointer_type c_str() const
Returns the value as a const C string.
static int OpenFile(Path file, int flags, int mode)
Wrapper for open_cloexec() that uses Path names.
bool IsNull() const
Check if this is a "nulled" instance.