summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/pid.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-11-21 01:30:40 +0000
committerLennart Poettering <lennart@poettering.net>2007-11-21 01:30:40 +0000
commit14a9b80afbb0bddc216462b72156f14e032e1b5e (patch)
tree4b76ca3fe8eb313a3d6e1eb866fdc1589383cfc6 /src/pulsecore/pid.c
parent4ac6b53478be63ae5d0163a330e67e4134f17f89 (diff)
- Check process name when dealing with PID files
- Add new PA_STREAM_FIX_CHANNELS, FIX_RATE, FIX_FORMAT, DONT_MOVE, VARIABLE_RATES to pa_sream_flags_t adn implement it - Expose those flags in pacat - Add notifications about device suspend/resume to the protocol and expose them in libpulse - Allow changing of buffer_attr during playback - allow disabling for remixing globally - hookup polkit support git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2067 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/pid.c')
-rw-r--r--src/pulsecore/pid.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/pulsecore/pid.c b/src/pulsecore/pid.c
index 55ff2088..f3c9faaa 100644
--- a/src/pulsecore/pid.c
+++ b/src/pulsecore/pid.c
@@ -42,6 +42,7 @@
#endif
#include <pulse/xmalloc.h>
+#include <pulse/util.h>
#include <pulsecore/core-error.h>
#include <pulsecore/core-util.h>
@@ -260,8 +261,8 @@ fail:
* exists and the PID therein too. Returns 0 on succcess, -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) {
- return pa_pid_file_kill(0, pid);
+int pa_pid_file_check_running(pid_t *pid, const char *binary_name) {
+ return pa_pid_file_kill(0, pid, binary_name);
}
#ifndef OS_IS_WIN32
@@ -269,12 +270,14 @@ int pa_pid_file_check_running(pid_t *pid) {
/* Kill a current running daemon. Return non-zero on success, -1
* otherwise. If successful *pid contains the PID of the daemon
* process. */
-int pa_pid_file_kill(int sig, pid_t *pid) {
+int pa_pid_file_kill(int sig, pid_t *pid, const char *binary_name) {
int fd = -1;
char fn[PATH_MAX];
int ret = -1;
pid_t _pid;
-
+#ifdef __linux__
+ char *e = NULL;
+#endif
if (!pid)
pid = &_pid;
@@ -286,6 +289,23 @@ int pa_pid_file_kill(int sig, pid_t *pid) {
if ((*pid = read_pid(fn, fd)) == (pid_t) -1)
goto fail;
+#ifdef __linux__
+ if (binary_name) {
+ pa_snprintf(fn, sizeof(fn), "/proc/%lu/exe", (unsigned long) pid);
+
+ if ((e = pa_readlink(fn))) {
+ char *f = pa_path_get_filename(e);
+ if (strcmp(f, binary_name)
+#if defined(__OPTIMIZE__)
+ /* libtool likes to rename our binary names ... */
+ && !(pa_startswith(f, "lt-") && strcmp(f+3, binary_name) == 0)
+#endif
+ )
+ goto fail;
+ }
+ }
+#endif
+
ret = kill(*pid, sig);
fail:
@@ -295,13 +315,17 @@ fail:
pa_close(fd);
}
+#ifdef __linux__
+ pa_xfree(e);
+#endif
+
return ret;
}
#else /* OS_IS_WIN32 */
-int pa_pid_file_kill(int sig, pid_t *pid) {
+int pa_pid_file_kill(int sig, pid_t *pid, const char *exe_name) {
return -1;
}