ldap/admin/src/scripts/DSCreate.pm.in | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
New commits: commit a16da9c70e64b59f145aa5a01fadbfe8430f8265 Author: William Brown firstyear@redhat.com Date: Wed May 4 11:49:53 2016 +1000
Ticket 48818 - In docker, no one can hear your process hang.
Bug Description: Docker starts the first process as pid 1. But pid 1 is special. It's meant to clean up zombies (defunct) processes.
However, our perl code in setup-ds.pl, when we called $startcmd, the start-dirsrv process was being left defucnt.
Issue is, that because it's defunct, the pid exists, as do the fds. Perl never returns. Our tests all fail, and setup-ds.pl hangs.
Fix Description: To fix this, we need to implement the process reaping capability of pid 1 into part of our perl code.
https://fedorahosted.org/389/ticket/48818
Author: wibrown
Review by: nhosoi (Thank you!)
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in index 55ecf45..8c3fd04 100644 --- a/ldap/admin/src/scripts/DSCreate.pm.in +++ b/ldap/admin/src/scripts/DSCreate.pm.in @@ -34,6 +34,8 @@ use Mozilla::LDAP::Utils qw(normalizeDN); use Mozilla::LDAP::API qw(ldap_explode_dn); use Mozilla::LDAP::LDIF;
+use POSIX ":sys_wait_h"; + use Exporter; @ISA = qw(Exporter); @EXPORT = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts @@ -713,14 +715,20 @@ sub startServer { $timeout = time + $timeout;
debug(1, "Starting the server: $startcmd\n"); - $? = 0; # clear error condition - my $output = `$startcmd 2>&1`; - $code = $?; - debug(1, "Started the server: code $code\n"); + + # 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"); + if ($cpid) { + # Parent process + waitpid($cpid,0); + } + close($output); + my $code = $?; if ($code) { - debug(0, $output); + debug(0, "Process returned $code"); } else { - debug(1, $output); + debug(1, "Process returned $code"); }
# try to open the server error log
389-commits@lists.fedoraproject.org