diff --git a/debian/changelog b/debian/changelog index 1cd84287..a08398c7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ byobu (4.21) unreleased; urgency=low [ Scott Moser ] * usr/bin/byobu-ctrl-a: - support taking an argument screen|emacs on the command line + * usr/bin/byobu-statusd, usr/lib/byobu/.shutil: + - avoid forks on the $(date) command -- Dustin Kirkland Wed, 20 Jul 2011 08:57:52 -0500 diff --git a/usr/bin/byobu-statusd b/usr/bin/byobu-statusd index 12649dce..2762c934 100755 --- a/usr/bin/byobu-statusd +++ b/usr/bin/byobu-statusd @@ -38,7 +38,7 @@ while true; do rm -f "$BYOBU_RUN_DIR/status"/* "$BYOBU_RUN_DIR/.last"/* exit 0 fi - now=$(date +%s) + getnow; now=${_RET} # Re-source configuration, if changed since last run for i in "${BYOBU_PREFIX}/share/$PKG/status/status" "${BYOBU_PREFIX}/share/$PKG/status/statusrc" "$BYOBU_CONFIG_DIR/status" "$BYOBU_CONFIG_DIR/statusrc"; do [ -r "$i" ] && [ "$i" -nt "$BYOBU_RUN_DIR/status" ] && . "$i" @@ -57,6 +57,11 @@ while true; do continue fi [ -r "$last" ] && read lastrun < "$last" || lastrun=0 + + # if, for any reason the lastrun has a value greater that + # current time, we should run again + [ $lastrun -le $now ] || lastrun=0 + status_freq "$i" expiry=$(($lastrun+$_RET)) find_script "$i" && path="$_RET" || path=/dev/null @@ -65,7 +70,7 @@ while true; do if [ "$path" -nt "$last" ] || [ ! -e "$last" ]; then . "$path" fi - eval "__$i" > "$cache" + "__$i" > "$cache" echo "$now" > "$last" fi done diff --git a/usr/lib/byobu/.shutil b/usr/lib/byobu/.shutil index e0db59f2..5b47ef11 100755 --- a/usr/lib/byobu/.shutil +++ b/usr/lib/byobu/.shutil @@ -257,4 +257,18 @@ status_freq() { esac } +getnow() { _RET=$(date +%s); } +if [ -n "${BASH_VERSION}" -a -n "${SECONDS}" ]; then + getnow() { + _RET=${SECONDS} + } +elif [ -r /proc/cpuinfo ]; then + getnow() { + # return the integer part of the first item in /proc/uptime + local s c + read s c < /proc/uptime + _RET=${s%.*} + } +fi + # vi: syntax=sh ts=4 noexpandtab