• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /***
3   This file is part of PulseAudio.
4 
5   Copyright 2004-2006 Lennart Poettering
6 
7   PulseAudio is free software; you can redistribute it and/or modify
8   it under the terms of the GNU Lesser General Public License as published
9   by the Free Software Foundation; either version 2.1 of the License,
10   or (at your option) any later version.
11 
12   PulseAudio is distributed in the hope that it will be useful, but
13   WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   General Public License for more details.
16 
17   You should have received a copy of the GNU Lesser General Public License
18   along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
19 ***/
20 
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24 
25 #include <unistd.h>
26 #include <errno.h>
27 #include <signal.h>
28 
29 #include <pulsecore/core-error.h>
30 #include <pulsecore/module.h>
31 #include <pulsecore/modargs.h>
32 #include <pulsecore/log.h>
33 
34 PA_MODULE_AUTHOR("Lennart Poettering");
35 PA_MODULE_DESCRIPTION("ESOUND compatibility module: -spawnpid emulation");
36 PA_MODULE_VERSION(PACKAGE_VERSION);
37 PA_MODULE_LOAD_ONCE(true);
38 PA_MODULE_USAGE("pid=<process id>");
39 
40 static const char* const valid_modargs[] = {
41     "pid",
42     NULL,
43 };
44 
pa__init(pa_module * m)45 int pa__init(pa_module*m) {
46     pa_modargs *ma = NULL;
47     int ret = -1;
48     uint32_t pid = 0;
49 
50     pa_assert(m);
51 
52     if (!(ma = pa_modargs_new(m->argument, valid_modargs)) ||
53         pa_modargs_get_value_u32(ma, "pid", &pid) < 0 ||
54         !pid) {
55         pa_log("Failed to parse module arguments");
56         goto finish;
57     }
58 
59     if (kill((pid_t) pid, SIGUSR1) < 0)
60         pa_log_warn("kill(%u) failed: %s", pid, pa_cstrerror(errno));
61 
62     pa_module_unload_request(m, true);
63 
64     ret = 0;
65 
66 finish:
67     if (ma)
68         pa_modargs_free(ma);
69 
70     return ret;
71 }
72