<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/4.6.6">
</HEAD>
<BODY>
Hell Michal,<BR>
<BR>
Thank you for your answer, but this doesn't fix my problem.<BR>
<BR>
Run your fixed script and we get the same behavior:<BR>
<BR>
<PRE>
<FONT SIZE="1">$ perl test-chldhandle-bug-fixed.pl </FONT>
<FONT SIZE="1">init... pid=29713</FONT>
<FONT SIZE="1">while...</FONT>
<FONT SIZE="1">fork 1</FONT>
<FONT SIZE="1">end... pid=29716</FONT>
<FONT SIZE="1">receive chld</FONT>
<FONT SIZE="1">fork 2</FONT>
<FONT SIZE="1">end... pid=29717</FONT>
<FONT SIZE="1">receive chld</FONT>
<FONT SIZE="1">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)</FONT>
<FONT SIZE="1">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</FONT>
<FONT SIZE="1">connection open</FONT>
<FONT SIZE="1">fork 3</FONT>
<FONT SIZE="1">end... pid=29827</FONT>
<FONT SIZE="1">fork 4</FONT>
<FONT SIZE="1">end... pid=29930</FONT>
<FONT SIZE="1">go next...</FONT>
</PRE>
<BR>
<BR>
In my daemon version, i also use waitpid for child treatment.<BR>
<BR>
Regards,<BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
-- 
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
</PRE>
<BR>
<BR>
</TD>
</TR>
</TABLE>
On Seg, 2014-03-17 at 12:04 +0100, Michal Privoznik wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
On 17.03.2014 11:13, Carlos Rodrigues wrote:
<FONT COLOR="#737373">> Hello,</FONT>
<FONT COLOR="#737373">></FONT>
<FONT COLOR="#737373">> Does anyone can help me? I a need a solution for this, 'cause i have a</FONT>
<FONT COLOR="#737373">> process/daemon, it reaches about 200 zombie processes, after open a new</FONT>
<FONT COLOR="#737373">> libvirt connection with qemu+tls.</FONT>
<FONT COLOR="#737373">></FONT>
<FONT COLOR="#737373">> Best regards,</FONT>
<FONT COLOR="#737373">></FONT>

 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
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>