Fixing PID file behavior
authorJohn Hodge <[email protected]>
Fri, 4 Mar 2011 08:40:31 +0000 (16:40 +0800)
committerJohn Hodge <[email protected]>
Fri, 4 Mar 2011 08:40:31 +0000 (16:40 +0800)
src/server/server.c

index de79f41..0a1a718 100644 (file)
@@ -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");
 }
 
 /**

UCC git Repository :: git.ucc.asn.au