~ubuntu-branches/ubuntu/oneiric/pulseaudio/oneiric

« back to all changes in this revision

Viewing changes to src/pulsecore/pid.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2007-12-04 00:56:08 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071204005608-y1xqvcu45g1yxtlu
Tags: 0.9.8-1ubuntu1
"Hail our new PulseAudio overlords (part two)."

* Merge from Debian unstable.
* Ubuntu-specific changes:
  - debian/control:
    + Don't build-depend on libjack0.100.0-dev or build jack module
      packages,
    + Update pulseaudio's Recommends and Suggests to accomodate
      existing promoted main packages,
    + Explicitly mention pasuspender in pulseaudio-utils's long
      description,
    + Add Vcs-Bzr URI,
    + Adhere to DebianMaintainerField;
  - debian/rules: Use multiuser for update-rc.d;
  - debian/patches/series: Retain the exclusion of
    0001-Set-ESD-socket-to-tmp-.esd-socket-to-match-up-with.patch.
* Dropped Ubuntu-specific change (absorbed into Debian source):
  debian/patches/0002-Double-esound-maximum-sample-size.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: pid.c 1971 2007-10-28 19:13:50Z lennart $ */
 
1
/* $Id: pid.c 2067 2007-11-21 01:30:40Z lennart $ */
2
2
 
3
3
/***
4
4
  This file is part of PulseAudio.
42
42
#endif
43
43
 
44
44
#include <pulse/xmalloc.h>
 
45
#include <pulse/util.h>
45
46
 
46
47
#include <pulsecore/core-error.h>
47
48
#include <pulsecore/core-util.h>
260
261
 * exists and the PID therein too. Returns 0 on succcess, -1
261
262
 * otherwise. If pid is non-NULL and a running daemon was found,
262
263
 * return its PID therein */
263
 
int pa_pid_file_check_running(pid_t *pid) {
264
 
    return pa_pid_file_kill(0, pid);
 
264
int pa_pid_file_check_running(pid_t *pid, const char *binary_name) {
 
265
    return pa_pid_file_kill(0, pid, binary_name);
265
266
}
266
267
 
267
268
#ifndef OS_IS_WIN32
269
270
/* Kill a current running daemon. Return non-zero on success, -1
270
271
 * otherwise. If successful *pid contains the PID of the daemon
271
272
 * process. */
272
 
int pa_pid_file_kill(int sig, pid_t *pid) {
 
273
int pa_pid_file_kill(int sig, pid_t *pid, const char *binary_name) {
273
274
    int fd = -1;
274
275
    char fn[PATH_MAX];
275
276
    int ret = -1;
276
277
    pid_t _pid;
277
 
 
 
278
#ifdef __linux__
 
279
    char *e = NULL;
 
280
#endif
278
281
    if (!pid)
279
282
        pid = &_pid;
280
283
 
286
289
    if ((*pid = read_pid(fn, fd)) == (pid_t) -1)
287
290
        goto fail;
288
291
 
 
292
#ifdef __linux__
 
293
    if (binary_name) {
 
294
        pa_snprintf(fn, sizeof(fn), "/proc/%lu/exe", (unsigned long) pid);
 
295
 
 
296
        if ((e = pa_readlink(fn))) {
 
297
            char *f = pa_path_get_filename(e);
 
298
            if (strcmp(f, binary_name)
 
299
#if defined(__OPTIMIZE__)
 
300
                /* libtool likes to rename our binary names ... */
 
301
                && !(pa_startswith(f, "lt-") && strcmp(f+3, binary_name) == 0)
 
302
#endif
 
303
            )
 
304
                goto fail;
 
305
        }
 
306
    }
 
307
#endif
 
308
 
289
309
    ret = kill(*pid, sig);
290
310
 
291
311
fail:
295
315
        pa_close(fd);
296
316
    }
297
317
 
 
318
#ifdef __linux__
 
319
    pa_xfree(e);
 
320
#endif
 
321
 
298
322
    return ret;
299
323
 
300
324
}
301
325
 
302
326
#else /* OS_IS_WIN32 */
303
327
 
304
 
int pa_pid_file_kill(int sig, pid_t *pid) {
 
328
int pa_pid_file_kill(int sig, pid_t *pid, const char *exe_name) {
305
329
    return -1;
306
330
}
307
331