Implemented `dispense -c`, bound SIGTERM to clean exist, re-created the pidfile
[tpg/opendispense2.git] / src / server / server.c
index dbcc94b..2557436 100644 (file)
@@ -144,11 +144,11 @@ void Server_Start(void)
        printf("Listening on 0.0.0.0:%i\n", giServer_Port);
        
        // write pidfile
-//     {
-//             FILE *fp = fopen("/var/run/dispsrv.pid", "w");
-//             fprintf(fp, "%i", getpid());
-//             fclose(fp);
-//     }
+       {
+               FILE *fp = fopen("/var/run/dispsrv.pid", "w");
+               fprintf(fp, "%i", getpid());
+               fclose(fp);
+       }
 
        for(;;)
        {
@@ -215,7 +215,7 @@ void Server_Start(void)
 
 void Server_Cleanup(void)
 {
-       printf("Close(%i)\n", giServer_Socket);
+       printf("\nClose(%i)\n", giServer_Socket);
        close(giServer_Socket);
 }
 
@@ -310,6 +310,7 @@ void Server_ParseClientCommand(tClient *Client, char *CommandString)
        
        if( Server_int_ParseArgs(1, CommandString, &command, &args, NULL) )
        {
+               if( command == NULL )   return ;
 //             printf("command=%s, args=%s\n", command, args);
                // Is this an error? (just ignore for now)
                //args = "";

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