[pisa-src] r1464 - trunk/libpisa/util.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Fri, 30 Oct 2009 14:00:34 +0100

Author: tjansen
Date: Fri Oct 30 14:00:34 2009
New Revision: 1464

Log:
Rewrote pisa_make_hipd_run.

This fixes warnings:
libpisa/util.c: In function ‘pisa_make_hipd_run’:
libpisa/util.c:274: warning: initialization discards qualifiers from pointer 
target type
libpisa/util.c:274: warning: initialization discards qualifiers from pointer 
target type

Also the function did not what it was supposed to do (i.e. return -1 if hipd
cannot be started, so the program may decide to quit). What was done instead
was a fork. The process executing execvp would return -1 properly and exit,
but the other one would continue and assume hipd is running.

Modified:
   trunk/libpisa/util.c

Modified: trunk/libpisa/util.c
==============================================================================
--- trunk/libpisa/util.c        Fri Oct 30 13:03:30 2009        (r1463)
+++ trunk/libpisa/util.c        Fri Oct 30 14:00:34 2009        (r1464)
@@ -269,23 +269,10 @@
  */
 int pisa_make_hipd_run(void)
 {
-       char *hipd_args[] = { "hipd", "-bk", (char *) 0 };
-
-       if (pisa_check_if_hipd_runs()) {
+       if (pisa_check_if_hipd_runs())
                return 0;
-       }
 
-       if (fork() == 0) {
-               PISA_INFO("Being forced to run hipd in background...\n");
-               if (execvp(hipd_args[0], hipd_args) == -1) {
-                       PISA_ERROR("Cannot run hipd. (%s)\n", strerror(errno));
-                       return -1;
-               }
-       }
-
-       /* no other way to make it run. stop. */
-
-       return 0;
+       return system("hipd -bk") == 0 ? 0 : -1;
 }
 
 /**

Other related posts:

  • » [pisa-src] r1464 - trunk/libpisa/util.c - Thomas Jansen