[Asterisk-cvs] asterisk asterisk.c,1.23,1.24
markster at lists.digium.com
markster at lists.digium.com
Thu Oct 16 05:01:39 CDT 2003
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv8279
Modified Files:
asterisk.c
Log Message:
Report proper pid when forking
Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- asterisk.c 29 Sep 2003 20:20:04 -0000 1.23
+++ asterisk.c 16 Oct 2003 10:27:41 -0000 1.24
@@ -1351,18 +1351,15 @@
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();
More information about the svn-commits
mailing list