Bug 217055 - Consolidate random sleeps in periodic scripts

Martin S. Weber Ephaeton at gmx.net
Tue Feb 14 11:42:28 UTC 2017


On 2017-02-13 22:47:31, Cy Schubert wrote:
(...)
> Hi Alan,
> 
> Looking at ntp, it backgrounds itself:
> 
> 	(sleep $(jot -r 1 0 3600); service ntpd onefetch) &
> 
> To facilitate debugging, I can commit the following, if you don't mind.
> 
> Index: periodic/daily/480.leapfile-ntpd
> ===================================================================
> --- periodic/daily/480.leapfile-ntpd	(revision 313710)
> +++ periodic/daily/480.leapfile-ntpd	(working copy)
> @@ -13,6 +13,7 @@
>  
>  case "$daily_ntpd_leapfile_enable" in
>      [Yy][Ee][Ss])
> +	tty >/dev/null 2>&1 && daily_ntpd_avoid_congestion=NO
>  	case "$daily_ntpd_avoid_congestion" in
>      	[Yy][Ee][Ss])
>  	    # Avoid dogpiling

You are aware that these files are invoked with < /dev/null and > file 2>&1 ?

Problem with sleeping from periodic from the command line is that these
extra I/O indirections make it impossible from the script file itself
to determine whether or not the parent process is running from a tty
or not.

Cf. /usr/sbin/periodic:118

For the purpose of "my" PR, your fix is useless. An environment variable
could be set that stored the fact whether or not invoker is on a TTY,
and this again be checked from within the periodic scripts themselves
to determine whether or not we should sleep.

Btw, I hate systemd & dbus, but the discussion so far really looks like
the vanilla argument "pro" SOA-style module startup :(

Regards,

-Martin


More information about the freebsd-pkg mailing list