From: John Hodge Date: Fri, 4 Mar 2011 08:40:31 +0000 (+0800) Subject: Fixing PID file behavior X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=22332ba1e9aa9dd8c80a16e9d541c8085c3e0d1e;p=tpg%2Fopendispense2.git Fixing PID file behavior --- diff --git a/src/server/server.c b/src/server/server.c index de79f41..0a1a718 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -177,8 +177,10 @@ void Server_Start(void) // write pidfile { FILE *fp = fopen("/var/run/dispsrv.pid", "w"); - fprintf(fp, "%i", getpid()); - fclose(fp); + if( fp ) { + fprintf(fp, "%i", getpid()); + fclose(fp); + } } for(;;) @@ -249,7 +251,7 @@ void Server_Cleanup(void) { printf("\nClose(%i)\n", giServer_Socket); close(giServer_Socket); - unlink("/var/run/dispsrv"); + unlink("/var/run/dispsrv.pid"); } /**