diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-10-16 10:27:41 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-10-16 10:27:41 +0000 |
commit | 99b4cfd0e443f57b12cb461391659b251572e900 (patch) | |
tree | 32679c0836203a47bdeb433c5f4eb52c10dc4385 /asterisk.c | |
parent | 6e20c666e6782f68a1ddd4614e28b47cd5819f41 (diff) |
Report proper pid when forking
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1634 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'asterisk.c')
-rwxr-xr-x | asterisk.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/asterisk.c b/asterisk.c index ac7173f4f..f419ac5c4 100755 --- a/asterisk.c +++ b/asterisk.c @@ -1351,18 +1351,15 @@ int main(int argc, char *argv[]) ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", (char *)ast_config_AST_PID, strerror(errno)); if (!option_verbose && !option_debug && !option_nofork && !option_console) { -#if 1 daemon(0,0); -#else - pid = fork(); - if (pid < 0) { - ast_log(LOG_ERROR, "Unable to fork(): %s\n", strerror(errno)); - printf(term_quit()); - exit(1); - } - if (pid) - exit(0); -#endif + /* Blindly re-write pid file since we are forking */ + unlink((char *)ast_config_AST_PID); + f = fopen((char *)ast_config_AST_PID, "w"); + if (f) { + fprintf(f, "%d\n", getpid()); + fclose(f); + } else + ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", (char *)ast_config_AST_PID, strerror(errno)); } ast_makesocket(); |