mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Report proper pid when forking
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1634 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
19
asterisk.c
19
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();
|
||||
|
Reference in New Issue
Block a user