Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 523766 - app-admin/sysstat - improper backgrounding in cron job leaves a persistent waiting cron daemon and a zombie bash process (possibly only in combination with vixie-cron)
Summary: app-admin/sysstat - improper backgrounding in cron job leaves a persistent wa...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jeroen Roovers (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-26 08:46 UTC by shino+bgo
Modified: 2014-09-26 09:02 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shino+bgo 2014-09-26 08:46:17 UTC
The cron job of app-admin/sysstat creates a ugly zombie process. The perpetrator is the hourly cron job of sysstat:

# cat /etc/cron.hourly/sysstat
> #!/bin/sh
> # Run system activity accounting tool every 10 minutes
> /usr/lib64/sa/sa1 600 6 &

The problem is that vixie-cron waits until stdout/stderr of the process (/bin/sh in this case) have been closed - which doesn't happen until /usr/lib64/sa/sa1 terminates (which runs for an hour). This leaves a zombie bash process and a waiting cron daemon.

One way to fix this issue is to make sure the background process doesn't inherit stdin/stdout:

> -/usr/lib64/sa/sa1 600 6 &
> +/usr/lib64/sa/sa1 600 6 2>/dev/null >/dev/null &

However the fix I would rather like to see is to use the /etc/cron.d crontab that is installed by sysstat. The crontab is automatically installed whenever the /etc/cron.d exists and is preferred over the /etc/cron.{daily,hourly} cronjobs. The crontab file does not try to launch any background processes and therefore doesn't exhibit this issue. I would therefore suggest applying the following modification to the ebuilds:

> --- /usr/portage/app-admin/sysstat/sysstat-11.0.0.ebuild        2014-09-24 13:01:02.000000000 +0200
> +++ /usr/local/portage/local/app-admin/sysstat/sysstat-11.0.0.ebuild   2014-09-25 17:35:57.212880210 +0200
> @@ -68,7 +68,7 @@
>  src_install() {
>         keepdir /var/log/sa
>  
> -       use cron && dodir /etc/cron.{daily,hourly}
> +       use cron && dodir /etc/cron.d
>  
>         emake \
>                 DESTDIR="${D}" \

Reproducible: Always

Steps to Reproduce:
1. Install app-admin/sysstat with cron useflag (using vixie-cron)
2. Wait until cron job is run (max. 1 hour)
3. Observe process list
Actual Results:  
Zombie bash process parented to cron.

root     19937  0.0  0.0  19864   840 ?        Ss   Sep16   0:01 /usr/sbin/cron
root     14192  0.0  0.0  28440  1016 ?        S    10:00   0:00  \_ /usr/sbin/cron
root     14197  0.0  0.0      0     0 ?        Zs   10:00   0:00      \_ [bash] <defunct>
...
root     15352  0.0  0.0   4280   848 ?        S    10:00   0:00 /usr/lib64/sa/sadc -F -L 600 6 /var/log/sa

Expected Results:  
No zombie bash and waiting cron processes.

app-admin/sysstat: 11.0.0
sys-process/vixie-cron: 4.1-r14
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2014-09-26 09:02:10 UTC
+*sysstat-11.1.1-r1 (26 Sep 2014)
+*sysstat-11.0.1-r1 (26 Sep 2014)
+
+  26 Sep 2014; Jeroen Roovers <jer@gentoo.org> -sysstat-11.0.1.ebuild,
+  +sysstat-11.0.1-r1.ebuild, -sysstat-11.1.1.ebuild, +sysstat-11.1.1-r1.ebuild:
+  Install alternative crontab file into /etc/cron.d instead of
+  /etc/cron.{daily,hourly} by shino (bug #523766).
+