#endif
#include <pulse/xmalloc.h>
-#include <pulse/util.h>
#include <pulsecore/core-error.h>
#include <pulsecore/core-util.h>
}
static int open_pid_file(const char *fn, int mode) {
- int fd = -1;
+ int fd;
pa_assert(fn);
for (;;) {
struct stat st;
- if ((fd = open(fn, mode
-#ifdef O_NOCTTY
- |O_NOCTTY
-#endif
+ if ((fd = pa_open_cloexec(fn, mode
#ifdef O_NOFOLLOW
|O_NOFOLLOW
#endif
fd = -1;
goto fail;
}
-
- fd = -1;
}
return fd;
pa_snprintf(bn, sizeof(bn), "/proc/%lu/stat", (unsigned long) pid);
- if (!(f = fopen(bn, "r"))) {
+ if (!(f = pa_fopen_cloexec(bn, "r"))) {
pa_log_info("Failed to open %s: %s", bn, pa_cstrerror(errno));
return -1;
} else {
char *expected;
- pa_bool_t good;
+ bool good;
char stored[64];
if (!(fgets(stored, sizeof(stored), f))) {
int ours = 1;
#ifdef OS_IS_WIN32
- if ((process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid)) != NULL) {
+ if ((process = OpenProcess(PROCESS_QUERY_INFORMATION, false, pid)) != NULL) {
CloseHandle(process);
#else
if (kill(pid, 0) >= 0 || errno != ESRCH) {
if (procname)
if ((ours = proc_name_ours(pid, procname)) < 0) {
pa_log_warn("Could not check to see if pid %lu is a pulseaudio process. "
- "Asssuming it is and the daemon is already running.", (unsigned long) pid);
+ "Assuming it is and the daemon is already running.", (unsigned long) pid);
goto fail;
}
}
/* Check whether the daemon is currently running, i.e. if a PID file
- * exists and the PID therein too. Returns 0 on succcess, -1
+ * exists and the PID therein too. Returns 0 on success, -1
* otherwise. If pid is non-NULL and a running daemon was found,
* return its PID therein */
int pa_pid_file_check_running(pid_t *pid, const char *procname) {