From: Michael Jerris Date: Fri, 7 Dec 2007 02:03:55 +0000 (+0000) Subject: cleanup pid file on orderly exit. X-Git-Tag: v1.0-rc1~1264 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bad7635ddd80fbd51a3c1cc0c03afe404230e00;p=thirdparty%2Ffreeswitch.git cleanup pid file on orderly exit. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6559 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/switch.c b/src/switch.c index 854b923e30..9028749c2e 100644 --- a/src/switch.c +++ b/src/switch.c @@ -214,6 +214,7 @@ int main(int argc, char *argv[]) int known_opt; int high_prio = 0; switch_core_flag_t flags = SCF_USE_SQL; + int status; #ifdef WIN32 SERVICE_TABLE_ENTRY dispatchTable[] = { @@ -428,11 +429,16 @@ int main(int argc, char *argv[]) } fprintf(f, "%d", pid = getpid()); - fclose(f); + fflush(f); switch_core_runtime_loop(nc); - return switch_core_destroy(); + status = switch_core_destroy(); + + fclose(f); + unlink(pid_path); + + return status; } /* For Emacs: