Re: Zombie process after open libvirt connection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]