mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-19 08:57:14 -05:00
pulse-server: Use fprintf to write the pid file
This simplifies the code and also avoids a warning with _FORTIFY_SOURCE:
../pipewire/src/modules/module-protocol-pulse/pulse-server.c: In function ‘create_pid_file’:
../pipewire/src/modules/module-protocol-pulse/pulse-server.c:6028:2: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6028 | write(fd, pid_str, strlen(pid_str) + 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
parent
ac9bcdee31
commit
c6aa48548e
1 changed files with 5 additions and 7 deletions
|
|
@ -6010,7 +6010,7 @@ error:
|
||||||
static int create_pid_file(void) {
|
static int create_pid_file(void) {
|
||||||
int res;
|
int res;
|
||||||
char pid_file[PATH_MAX];
|
char pid_file[PATH_MAX];
|
||||||
char pid_str[32];
|
FILE *f;
|
||||||
|
|
||||||
if ((res = get_runtime_dir(pid_file, sizeof(pid_file), "pulse")) < 0) {
|
if ((res = get_runtime_dir(pid_file, sizeof(pid_file), "pulse")) < 0) {
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -6021,16 +6021,14 @@ static int create_pid_file(void) {
|
||||||
}
|
}
|
||||||
strcat(pid_file, "/pid");
|
strcat(pid_file, "/pid");
|
||||||
|
|
||||||
snprintf(pid_str, sizeof(pid_str), "%lu\n", (unsigned long)getpid());
|
if ((f = fopen(pid_file, "w")) == NULL) {
|
||||||
|
|
||||||
int fd = open(pid_file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
|
|
||||||
if (fd < 0) {
|
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_error(NAME" failed to open pid file");
|
pw_log_error(NAME" failed to open pid file");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
write(fd, pid_str, strlen(pid_str) + 1);
|
|
||||||
close(fd);
|
fprintf(f, "%lu\n", (unsigned long)getpid());
|
||||||
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue