mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 14:24:39 -07:00
* usr/bin/byobu-statusd, usr/lib/byobu/.shutil:
- avoid forks on the $(date) command
This commit is contained in:
commit
7024df42f3
3 changed files with 23 additions and 2 deletions
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -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 <kirkland@ubuntu.com> Wed, 20 Jul 2011 08:57:52 -0500
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue