Browse Source

Ticket 48818 - Fix case where return code is always -1

Bug Description:  Due to the docker process fixes, this made certain scripts
return the wrong code.

Fix Description:  Fix the location where we get the return code.

In addition, this fix showed an issue in the start-dirsrv script that has
existed for a long time. This corrects that issue also.

https://fedorahosted.org/389/ticket/48818

Author: wibrown

Review by: mreynolds (Thanks!)
William Brown 9 years ago
parent
commit
cbb8bf4b26
2 changed files with 9 additions and 8 deletions
  1. 4 3
      ldap/admin/src/scripts/DSCreate.pm.in
  2. 5 5
      ldap/admin/src/scripts/start-dirsrv.in

+ 4 - 3
ldap/admin/src/scripts/DSCreate.pm.in

@@ -719,16 +719,17 @@ sub startServer {
     # We have to do this because docker is incapable of sane process management
     # Sadly we have to sacrifice output collection, because of perl issues
     my $cpid = open(my $output, "-|", "$startcmd 2>&1");
+    my $code = -512;
     if ($cpid) {
         # Parent process
         waitpid($cpid,0);
+        $code = $?;
     }
     close($output);
-    my $code = $?;
     if ($code) {
-        debug(0, "Process returned $code");
+        debug(0, "Process returned $code\n");
     } else {
-        debug(1, "Process returned $code");
+        debug(1, "Process returned $code\n");
     }
 
     # try to open the server error log

+ 5 - 5
ldap/admin/src/scripts/start-dirsrv.in

@@ -80,15 +80,15 @@ start_instance() {
         loop_counter=`expr $loop_counter + 1`
         if test -f $PIDFILE ; then
             PID=`cat $PIDFILE`
-            return 0;
-        else
-            # I'm not sure what this meant to achieve, but $PID is 0 here.
-            if kill -s 0 $PID > /dev/null 2>&1 ; then
-                sleep 1
+            # if kill -s 0 $PID > /dev/null 2>&1 ; then
+            if kill -s 0 $PID ; then
+                return 0;
             else
                 echo Server failed to start !!! Please check errors log for problems
                 return 1
             fi
+        else
+            sleep 1
         fi
     done
     echo Server not running!! Failed to start ns-slapd process.  Please check the errors log for problems.