mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
pulse-server: create pid file on start up
Some PulseAudio clients, such as QEMU, check that the pid file exists prior to initialization.
This commit is contained in:
parent
a9bf93030e
commit
2ae6851698
1 changed files with 26 additions and 0 deletions
|
|
@ -6007,6 +6007,29 @@ error:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int create_pid_file(void) {
|
||||||
|
int res;
|
||||||
|
char pid_file[PATH_MAX];
|
||||||
|
char pid_str[32];
|
||||||
|
|
||||||
|
if ((res = get_runtime_dir(pid_file, sizeof(pid_file), "pulse")) < 0) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
strcat(pid_file, "/pid");
|
||||||
|
|
||||||
|
snprintf(pid_str, sizeof(pid_str), "%lu\n", (unsigned long)getpid());
|
||||||
|
|
||||||
|
int fd = open(pid_file, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
|
||||||
|
if (fd < 0) {
|
||||||
|
res = -errno;
|
||||||
|
pw_log_error(NAME" failed to open pid file");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
write(fd, pid_str, strlen(pid_str) + 1);
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int make_inet_socket(struct server *server, char *name)
|
static int make_inet_socket(struct server *server, char *name)
|
||||||
{
|
{
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
|
|
@ -6097,6 +6120,9 @@ static struct server *create_server(struct impl *impl, char *address)
|
||||||
pw_log_error(NAME" %p: can't create server source: %m", impl);
|
pw_log_error(NAME" %p: can't create server source: %m", impl);
|
||||||
goto error_close;
|
goto error_close;
|
||||||
}
|
}
|
||||||
|
if ((res = create_pid_file()) < 0) {
|
||||||
|
goto error_close;
|
||||||
|
}
|
||||||
return server;
|
return server;
|
||||||
|
|
||||||
error_close:
|
error_close:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue