Hell Michal,
Thank you for your answer, but this doesn't fix my problem.
Run your fixed script and we get the same behavior:
$ perl test-chldhandle-bug-fixed.pl
init... pid=29713
while...
fork 1
end... pid=29716
receive chld
fork 2
end... pid=29717
receive chld
2014-03-17 11:10:37.234+0000: 29713: info : libvirt version: 1.0.5.7, package: 2.fc19
(Fedora Project, 2013-11-17-23:21:57,
buildvm-18.phx2.fedoraproject.org)
2014-03-17 11:10:37.234+0000: 29713: warning : virNetTLSContextCheckCertificate:1099 :
Certificate check failed Certificate [session] owner does not match the hostname
10.10.4.249
connection open
fork 3
end... pid=29827
fork 4
end... pid=29930
go next...
In my daemon version, i also use waitpid for child treatment.
Regards,
--
Carlos Rodrigues
Engenheiro de Software Sénior
Eurotux Informática, S.A. |
www.eurotux.com
(t) +351 253 680 300 (m) +351 911 926 110
On Seg, 2014-03-17 at 12:04 +0100, Michal Privoznik wrote:
On 17.03.2014 11:13, Carlos Rodrigues wrote:
> Hello,
>
> Does anyone can help me? I a need a solution for this, 'cause i have a
> process/daemon, it reaches about 200 zombie processes, after open a new
> libvirt connection with qemu+tls.
>
> Best regards,
>
From the script you've attached:
$SIG{'CHLD'} = sub { print "receive chld","\n"; };
You should either waitpid() child here or at the end of the script. The
former approach won't leave any zombies hanging around, the latter
requires you to keep return values of fork(). So I think your script
needs to look like this:
$ diff -up test-chldhandle-bug.pl test-chldhandle-bug-fixed.pl
--- test-chldhandle-bug.pl 2014-03-17 11:59:48.972238074 +0100
+++ test-chldhandle-bug-fixed.pl 2014-03-17 12:03:08.693875968 +0100
@@ -5,10 +5,12 @@ use strict;
use Sys::Virt;
use POSIX qw(:signal_h);
+use POSIX ":sys_wait_h";
sub main {
print "init... pid=$$","\n";
- $SIG{'CHLD'} = sub { print "receive chld","\n"; };
+ $SIG{'CHLD'} = sub { my $kid; print "receive
chld","\n";
+ do { $kid = waitpid(-1, WNOHANG); } while $kid > 0; };
while(1){
print "while...","\n";
Michal