mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-10 13:29:58 -05:00
add new switch --disallow-exit
This commit is contained in:
parent
f1d2bf8408
commit
756fac8d04
11 changed files with 87 additions and 52 deletions
|
|
@ -50,6 +50,7 @@ enum {
|
|||
ARG_HIGH_PRIORITY,
|
||||
ARG_REALTIME,
|
||||
ARG_DISALLOW_MODULE_LOADING,
|
||||
ARG_DISALLOW_EXIT,
|
||||
ARG_EXIT_IDLE_TIME,
|
||||
ARG_MODULE_IDLE_TIME,
|
||||
ARG_SCACHE_IDLE_TIME,
|
||||
|
|
@ -82,6 +83,7 @@ static const struct option long_options[] = {
|
|||
{"high-priority", 2, 0, ARG_HIGH_PRIORITY},
|
||||
{"realtime", 2, 0, ARG_REALTIME},
|
||||
{"disallow-module-loading", 2, 0, ARG_DISALLOW_MODULE_LOADING},
|
||||
{"disallow-exit", 2, 0, ARG_DISALLOW_EXIT},
|
||||
{"exit-idle-time", 2, 0, ARG_EXIT_IDLE_TIME},
|
||||
{"module-idle-time", 2, 0, ARG_MODULE_IDLE_TIME},
|
||||
{"scache-idle-time", 2, 0, ARG_SCACHE_IDLE_TIME},
|
||||
|
|
@ -134,7 +136,9 @@ void pa_cmdline_help(const char *argv0) {
|
|||
" --realtime[=BOOL] Try to enable realtime scheduling\n"
|
||||
" (only available as root, when SUID or\n"
|
||||
" with elevated RLIMIT_RTPRIO)\n"
|
||||
" --disallow-module-loading[=BOOL] Disallow module loading after startup\n"
|
||||
" --disallow-module-loading[=BOOL] Disallow module user requested module\n"
|
||||
" loading/unloading after startup\n"
|
||||
" --disallow-exit[=BOOL] Disallow user requested exit\n"
|
||||
" --exit-idle-time=SECS Terminate the daemon when idle and this\n"
|
||||
" time passed\n"
|
||||
" --module-idle-time=SECS Unload autoloaded modules when idle and\n"
|
||||
|
|
@ -286,6 +290,13 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
|
|||
}
|
||||
break;
|
||||
|
||||
case ARG_DISALLOW_EXIT:
|
||||
if ((conf->disallow_exit = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
|
||||
pa_log(_("--disallow-exit boolean argument"));
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
case ARG_USE_PID_FILE:
|
||||
if ((conf->use_pid_file = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
|
||||
pa_log(_("--use-pid-file expects boolean argument"));
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ static const pa_daemon_conf default_conf = {
|
|||
.realtime_scheduling = FALSE,
|
||||
.realtime_priority = 5, /* Half of JACK's default rtprio */
|
||||
.disallow_module_loading = FALSE,
|
||||
.disallow_exit = FALSE,
|
||||
.exit_idle_time = 20,
|
||||
.module_idle_time = 20,
|
||||
.scache_idle_time = 20,
|
||||
|
|
@ -403,6 +404,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
|
|||
{ "high-priority", pa_config_parse_bool, NULL },
|
||||
{ "realtime-scheduling", pa_config_parse_bool, NULL },
|
||||
{ "disallow-module-loading", pa_config_parse_bool, NULL },
|
||||
{ "disallow-exit", pa_config_parse_bool, NULL },
|
||||
{ "use-pid-file", pa_config_parse_bool, NULL },
|
||||
{ "system-instance", pa_config_parse_bool, NULL },
|
||||
{ "no-cpu-limit", pa_config_parse_bool, NULL },
|
||||
|
|
@ -466,17 +468,17 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
|
|||
table[2].data = &c->high_priority;
|
||||
table[3].data = &c->realtime_scheduling;
|
||||
table[4].data = &c->disallow_module_loading;
|
||||
table[5].data = &c->use_pid_file;
|
||||
table[6].data = &c->system_instance;
|
||||
table[7].data = &c->no_cpu_limit;
|
||||
table[8].data = &c->disable_shm;
|
||||
table[9].data = &c->exit_idle_time;
|
||||
table[10].data = &c->module_idle_time;
|
||||
table[11].data = &c->scache_idle_time;
|
||||
table[12].data = c;
|
||||
table[13].data = &c->dl_search_path;
|
||||
table[14].data = &c->default_script_file;
|
||||
table[15].data = c;
|
||||
table[5].data = &c->disallow_exit;
|
||||
table[6].data = &c->use_pid_file;
|
||||
table[7].data = &c->system_instance;
|
||||
table[8].data = &c->no_cpu_limit;
|
||||
table[9].data = &c->disable_shm;
|
||||
table[10].data = &c->exit_idle_time;
|
||||
table[11].data = &c->module_idle_time;
|
||||
table[12].data = &c->scache_idle_time;
|
||||
table[13].data = c;
|
||||
table[14].data = &c->dl_search_path;
|
||||
table[15].data = &c->default_script_file;
|
||||
table[16].data = c;
|
||||
table[17].data = c;
|
||||
table[18].data = c;
|
||||
|
|
@ -486,67 +488,68 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
|
|||
table[22].data = c;
|
||||
table[23].data = c;
|
||||
table[24].data = c;
|
||||
table[25].data = &c->disable_remixing;
|
||||
table[26].data = &c->load_default_script_file;
|
||||
table[25].data = c;
|
||||
table[26].data = &c->disable_remixing;
|
||||
table[27].data = &c->load_default_script_file;
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
table[27].data = &c->rlimit_fsize;
|
||||
table[28].data = &c->rlimit_data;
|
||||
table[29].data = &c->rlimit_stack;
|
||||
table[30].data = &c->rlimit_as;
|
||||
table[31].data = &c->rlimit_core;
|
||||
table[32].data = &c->rlimit_nofile;
|
||||
table[33].data = &c->rlimit_as;
|
||||
table[28].data = &c->rlimit_fsize;
|
||||
table[29].data = &c->rlimit_data;
|
||||
table[30].data = &c->rlimit_stack;
|
||||
table[31].data = &c->rlimit_as;
|
||||
table[32].data = &c->rlimit_core;
|
||||
table[33].data = &c->rlimit_nofile;
|
||||
table[34].data = &c->rlimit_as;
|
||||
#ifdef RLIMIT_NPROC
|
||||
table[34].data = &c->rlimit_nproc;
|
||||
table[35].data = &c->rlimit_nproc;
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_MEMLOCK
|
||||
#ifndef RLIMIT_NPROC
|
||||
#error "Houston, we have a numbering problem!"
|
||||
#endif
|
||||
table[35].data = &c->rlimit_memlock;
|
||||
table[36].data = &c->rlimit_memlock;
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_LOCKS
|
||||
#ifndef RLIMIT_MEMLOCK
|
||||
#error "Houston, we have a numbering problem!"
|
||||
#endif
|
||||
table[36].data = &c->rlimit_locks;
|
||||
table[37].data = &c->rlimit_locks;
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_SIGPENDING
|
||||
#ifndef RLIMIT_LOCKS
|
||||
#error "Houston, we have a numbering problem!"
|
||||
#endif
|
||||
table[37].data = &c->rlimit_sigpending;
|
||||
table[38].data = &c->rlimit_sigpending;
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_MSGQUEUE
|
||||
#ifndef RLIMIT_SIGPENDING
|
||||
#error "Houston, we have a numbering problem!"
|
||||
#endif
|
||||
table[38].data = &c->rlimit_msgqueue;
|
||||
table[39].data = &c->rlimit_msgqueue;
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_NICE
|
||||
#ifndef RLIMIT_MSGQUEUE
|
||||
#error "Houston, we have a numbering problem!"
|
||||
#endif
|
||||
table[39].data = &c->rlimit_nice;
|
||||
table[40].data = &c->rlimit_nice;
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_RTPRIO
|
||||
#ifndef RLIMIT_NICE
|
||||
#error "Houston, we have a numbering problem!"
|
||||
#endif
|
||||
table[40].data = &c->rlimit_rtprio;
|
||||
table[41].data = &c->rlimit_rtprio;
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_RTTIME
|
||||
#ifndef RLIMIT_RTTIME
|
||||
#error "Houston, we have a numbering problem!"
|
||||
#endif
|
||||
table[41].data = &c->rlimit_rttime;
|
||||
table[42].data = &c->rlimit_rttime;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -643,6 +646,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) {
|
|||
pa_strbuf_printf(s, "realtime-scheduling = %s\n", pa_yes_no(c->realtime_scheduling));
|
||||
pa_strbuf_printf(s, "realtime-priority = %i\n", c->realtime_priority);
|
||||
pa_strbuf_printf(s, "disallow-module-loading = %s\n", pa_yes_no(c->disallow_module_loading));
|
||||
pa_strbuf_printf(s, "disallow-exit = %s\n", pa_yes_no(c->disallow_exit));
|
||||
pa_strbuf_printf(s, "use-pid-file = %s\n", pa_yes_no(c->use_pid_file));
|
||||
pa_strbuf_printf(s, "system-instance = %s\n", pa_yes_no(c->system_instance));
|
||||
pa_strbuf_printf(s, "no-cpu-limit = %s\n", pa_yes_no(c->no_cpu_limit));
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@ typedef struct pa_daemon_conf {
|
|||
no_cpu_limit,
|
||||
disable_shm,
|
||||
disable_remixing,
|
||||
load_default_script_file;
|
||||
load_default_script_file,
|
||||
disallow_exit;
|
||||
int exit_idle_time,
|
||||
module_idle_time,
|
||||
scache_idle_time,
|
||||
|
|
|
|||
|
|
@ -813,6 +813,7 @@ int main(int argc, char *argv[]) {
|
|||
c->realtime_scheduling = !!conf->realtime_scheduling;
|
||||
c->disable_remixing = !!conf->disable_remixing;
|
||||
c->running_as_daemon = !!conf->daemonize;
|
||||
c->disallow_exit = conf->disallow_exit;
|
||||
|
||||
pa_assert_se(pa_signal_init(pa_mainloop_get_api(mainloop)) == 0);
|
||||
pa_signal_new(SIGINT, signal_callback, c);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue