aboutsummaryrefslogtreecommitdiffstats
path: root/asterisk.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-30 14:55:05 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-30 14:55:05 +0000
commite35f607185bd75ee360b81ac074776cae02550bb (patch)
tree612ef7405224b9af1822726b09b5a1752f34a7f1 /asterisk.c
parentfd0fef45bfd11a868409733a3995a988640b3309 (diff)
add a command-line flag and option to force forking, even with -v or -d
rename a flag to have the proper name git-svn-id: http://svn.digium.com/svn/asterisk/trunk@23675 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'asterisk.c')
-rw-r--r--asterisk.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/asterisk.c b/asterisk.c
index 93f6af8ef..db5bf122c 100644
--- a/asterisk.c
+++ b/asterisk.c
@@ -2179,6 +2179,9 @@ static void ast_readconfig(void)
/* Disable forking (-f at startup) */
} else if (!strcasecmp(v->name, "nofork")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_NO_FORK);
+ /* Always fork, even if verbose or debug are enabled (-F at startup) */
+ } else if (!strcasecmp(v->name, "alwaysfork")) {
+ ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_ALWAYS_FORK);
/* Run quietly (-q at startup ) */
} else if (!strcasecmp(v->name, "quiet")) {
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_QUIET);
@@ -2289,6 +2292,9 @@ int main(int argc, char *argv[])
/* Check for options */
while ((c = getopt(argc, argv, "tThfdvVqprRgciInx:U:G:C:L:M:")) != -1) {
switch (c) {
+ case 'F':
+ ast_set_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
+ break;
case 'd':
option_debug++;
ast_set_flag(&ast_options, AST_OPT_FLAG_NO_FORK);
@@ -2366,6 +2372,11 @@ int main(int argc, char *argv[])
}
}
+ if (ast_opt_always_fork && (ast_opt_remote || ast_opt_console)) {
+ ast_log(LOG_WARNING, "'alwaysfork' is not compatible with console or remote console mode; ignored\n");
+ ast_clear_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK);
+ }
+
/* For remote connections, change the name of the remote connection.
* We do this for the benefit of init scripts (which need to know if/when
* the main asterisk process has died yet). */
@@ -2506,7 +2517,7 @@ int main(int argc, char *argv[])
} else
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
- if (!option_verbose && !option_debug && !ast_opt_no_fork && !ast_opt_console) {
+ if (ast_opt_always_fork || !ast_opt_no_fork) {
daemon(0, 0);
/* Blindly re-write pid file since we are forking */
unlink(ast_config_AST_PID);