:: Re: [DNG] BUG: zombies increase whi…
Top Page
Delete this message
Reply to this message
Author: Edward Bartolo
Date:  
To: tilt!
CC: dng
Subject: Re: [DNG] BUG: zombies increase while running netman
Hi,

OK, poWaitOnExit added and zombies creation has been reduced. However,
I am still getting these:

3584 ?        00:00:00 kworker/u8:0
 3586 ?        00:00:00 kworker/1:3
 3588 ?        00:00:01 netman
 3623 ?        00:00:00 ifdown <defunct>
 3644 ?        00:00:00 kworker/0:0
 3645 ?        00:00:00 kworker/0:3
 3898 ?        00:00:00 ifup <defunct>
 4142 ?        00:00:00 ifdown <defunct>
 4163 ?        00:00:00 kworker/0:4
 4186 pts/0    00:00:00 ps


This means, I have to also add code to the backend to properly clean
up after terminating on every run.

It looks like the culprit is execl which is used in core_functions.c.
We must add some code to rid ourselves of zombies.

I found that to get rid of zombies this function is used:

    int status;
    waitpid(pid, &status, 0);


However, I need the child's pid.

I also found this code snippet using fork() to create a child process
and record its pid:

int status;
pid_t pid;

  pid = fork ();
  if (pid == 0)
    {
      /* This is the child process.  Execute the shell command. */
      execl (SHELL, SHELL, "-c", command, NULL);
      _exit (EXIT_FAILURE);
    }
  else if (pid < 0)
    /* The fork failed.  Report failure.  */
    status = -1;
  else
    /* This is the parent process.  Wait for the child to complete.  */
    if (waitpid (pid, &status, 0) != pid)
      status = -1;
  return status;



Therefore, to properly get rid of zombies, whenever execl is used, I have to:

if (fork() == 0) {
execl("/sbin/ifup", "ifup", ethx, (char *) NULL); // example from
core_functions.c
} else {
// failure of fork()
}
waitpid (pid, &status, 0); // this removes the zombie


Thanks.




On 30/08/2015, tilt! <tilt@???> wrote:
> Hi Edward,
>
> every subprocess that is started must be "waited on" for proper
> completion, or else it never terminates and becomes a zombie.
>
> In backend.pas, in function run_backend(), either use the option
> poWaitOnExit when creating AProcess or use the method
> WaitOnExit() after the output has been read from the backend.
>
> Kind regards,
> T.
>
>
> On 08/29/2015 10:41 PM, Edward Bartolo wrote:
>> Running "ps -e" while netman runs for a some time results in zombies as
>> follows:
>>
>> edbarx@edbarx-pc:~$ ps -e
>>    PID TTY          TIME CMD
>>      1 ?        00:00:00 init
>>      2 ?        00:00:00 kthreadd
>>      3 ?        00:00:05 ksoftirqd/0
>>      5 ?        00:00:00 kworker/0:0H
>>      7 ?        00:00:12 rcu_sched
>>      8 ?        00:00:00 rcu_bh
>>      9 ?        00:00:00 migration/0
>>     10 ?        00:00:00 watchdog/0
>>     11 ?        00:00:00 watchdog/1
>>     12 ?        00:00:00 migration/1
>>     13 ?        00:00:06 ksoftirqd/1
>>     15 ?        00:00:00 kworker/1:0H
>>     16 ?        00:00:00 khelper
>>     17 ?        00:00:00 kdevtmpfs
>>     18 ?        00:00:00 netns
>>     19 ?        00:00:00 khungtaskd
>>     20 ?        00:00:00 writeback
>>     21 ?        00:00:00 ksmd
>>     22 ?        00:00:00 khugepaged
>>     23 ?        00:00:00 crypto
>>     24 ?        00:00:00 kintegrityd
>>     25 ?        00:00:00 bioset
>>     26 ?        00:00:00 kblockd
>>     29 ?        00:00:00 kswapd0
>>     30 ?        00:00:00 fsnotify_mark
>>     36 ?        00:00:00 kthrotld
>>     37 ?        00:00:00 ipv6_addrconf
>>     39 ?        00:00:00 deferwq
>>     75 ?        00:00:00 khubd
>>     76 ?        00:00:00 acpi_thermal_pm
>>     77 ?        00:00:00 ata_sff
>>     78 ?        00:00:00 scsi_eh_0
>>     79 ?        00:00:00 scsi_tmf_0
>>     80 ?        00:00:00 scsi_eh_1
>>     81 ?        00:00:00 scsi_tmf_1
>>     85 ?        00:00:00 scsi_eh_2
>>     86 ?        00:00:00 scsi_tmf_2
>>     87 ?        00:00:00 scsi_eh_3
>>     88 ?        00:00:00 scsi_tmf_3
>>     95 ?        00:00:00 kworker/1:1H
>>     96 ?        00:00:00 kworker/0:1H
>>    118 ?        00:00:00 jbd2/sda9-8
>>    119 ?        00:00:00 ext4-rsv-conver
>>    309 ?        00:00:00 udevd
>>    359 ?        00:00:00 hd-audio0
>>    368 ?        00:00:00 kpsmoused
>>    389 ?        00:00:00 cfg80211
>>   1277 ?        00:00:00 rpcbind
>>   1305 ?        00:00:00 rpc.statd
>>   1310 ?        00:00:00 rpciod
>>   1312 ?        00:00:00 nfsiod
>>   1319 ?        00:00:00 rpc.idmapd
>>   1555 ?        00:00:00 rsyslogd
>>   1597 ?        00:00:00 atd
>>   1643 ?        00:00:00 acpid
>>   1665 ?        00:00:00 cron
>>   1726 ?        00:00:00 dbus-daemon
>>   1919 ?        00:00:05 xchat
>>   1965 ?        00:00:00 exim4
>>   1985 ?        00:00:00 slim
>>   2011 tty7     00:09:19 Xorg
>>   2012 tty1     00:00:00 getty
>>   2013 tty2     00:00:00 getty
>>   2014 tty3     00:00:00 getty
>>   2015 tty4     00:00:00 getty
>>   2016 tty5     00:00:00 getty
>>   2017 tty6     00:00:00 getty
>>   2030 ?        00:00:00 kauditd
>>   2032 ?        00:00:00 console-kit-dae
>>   2099 ?        00:00:00 polkitd
>>   2110 ?        00:00:00 sh
>>   2162 ?        00:00:00 ssh-agent
>>   2165 ?        00:00:00 dbus-launch
>>   2166 ?        00:00:00 dbus-daemon
>>   2176 ?        00:00:00 xfce4-session
>>   2178 ?        00:00:00 xfconfd
>>   2182 ?        00:00:00 gpg-agent
>>   2183 ?        00:00:02 xfwm4
>>   2185 ?        00:00:03 xfce4-panel
>>   2187 ?        00:00:00 xfsettingsd
>>   2189 ?        00:00:00 syndaemon
>>   2191 ?        00:00:00 xfdesktop
>>   2195 ?        00:00:00 xfce4-power-man
>>   2199 ?        00:00:01 xscreensaver
>>   2202 ?        00:00:00 xfce4-power-man
>>   2203 ?        00:00:00 xfce4-volumed
>>   2208 ?        00:00:00 upowerd
>>   2210 ?        00:00:00 panel-6-systray
>>   2213 ?        00:00:00 panel-2-actions
>>   2264 ?        00:00:45 netman
>>   2271 ?        00:00:00 backend <defunct>
>>   2272 ?        00:00:00 cat <defunct>
>>   2280 ?        00:00:00 ifup <defunct>
>>   2416 ?        00:00:00 at-spi-bus-laun
>>   2743 ?        00:00:00 kworker/1:1
>>   3809 ?        00:00:00 kworker/0:1
>>   4106 ?        00:00:00 kworker/u8:0
>>   4595 ?        00:00:00 kworker/1:0
>>   4834 ?        00:00:00 kworker/u8:2
>>   5130 ?        00:00:00 kworker/0:2
>>   5207 ?        00:00:00 kworker/1:2
>>   5732 ?        00:00:00 xfce4-terminal
>>   5736 ?        00:00:00 gnome-pty-helpe
>>   5737 pts/0    00:00:00 bash
>>   5755 ?        00:00:00 ps <defunct>
>>   5756 pts/0    00:00:00 ps
>>   7389 ?        00:00:00 ifdown <defunct>
>> 16124 ?        00:00:00 ifup <defunct>
>> 16135 ?        00:00:00 wpa_supplicant
>> 16189 ?        00:00:00 dhclient
>> 18393 ?        00:00:28 medit
>> 26622 ?        00:00:00 backend <defunct>
>> 26853 ?        00:00:00 backend <defunct>
>> 26886 ?        00:00:00 backend <defunct>
>> 26908 ?        00:00:00 backend <defunct>
>> 31536 ?        00:08:11 iceweasel

>>
>>
>> I found this suggestion to get rid of zombies. The link is this:
>> https://www.daniweb.com/software-development/cpp/threads/364407/handling-sigchld-to-prevent-zombie-processes
>>
>> What do you suggest?
>>
>>
>> Edward.
>> _______________________________________________
>> Dng mailing list
>> Dng@???
>> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
>>
>
> _______________________________________________
> Dng mailing list
> Dng@???
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
>