From 22332ba1e9aa9dd8c80a16e9d541c8085c3e0d1e Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 4 Mar 2011 16:40:31 +0800 Subject: [PATCH] Fixing PID file behavior --- src/server/server.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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"); } /** -- 2.20.1