ovs-xenserverd: Fix time-delay logic.
[openvswitch] / tests / test-timeval.c
index 7aa6867a8797ca48b33e928e92eccb00b12b5496..533f81aed3ff87e7e236628cb237d9ff800df591 100644 (file)
 
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "command-line.h"
 #include "daemon.h"
 #include "util.h"
 
@@ -83,6 +85,7 @@ usage(void)
 int
 main(int argc, char *argv[])
 {
+    proctitle_init(argc, argv);
     set_program_name(argv[0]);
     time_init();
 
@@ -93,7 +96,7 @@ main(int argc, char *argv[])
     } else if (!strcmp(argv[1], "daemon")) {
         /* Test that time still advances even in a daemon.  This is an
          * interesting test because fork() cancels the interval timer. */
-        char cwd[1024];
+        char cwd[1024], *pidfile;
         FILE *success;
 
         assert(getcwd(cwd, sizeof cwd) == cwd);
@@ -102,7 +105,9 @@ main(int argc, char *argv[])
 
         /* Daemonize, with a pidfile in the current directory. */
         set_detach();
-        set_pidfile(xasprintf("%s/test-timeval.pid", cwd));
+        pidfile = xasprintf("%s/test-timeval.pid", cwd);
+        set_pidfile(pidfile);
+        free(pidfile);
         set_no_chdir();
         daemonize();