From cbb8bf4b261a001f0183ff4abae49a8055a85ad3 Mon Sep 17 00:00:00 2001 From: William Brown Date: May 10 2016 00:19:32 +0000 Subject: 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!) --- diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in index 8c3fd04..cdbad35 100644 --- a/ldap/admin/src/scripts/DSCreate.pm.in +++ b/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 diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in index 410786b..e3c46e3 100755 --- a/ldap/admin/src/scripts/start-dirsrv.in +++ b/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.