summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-11-15 01:04:39 -0500
committerMike Frysinger <vapier@gentoo.org>2016-11-15 01:06:05 -0500
commitb11e8d8b4555479dce4054aca1feffb06c0066e6 (patch)
treec5a415a79312534e33d00ea8c4dd2c182fcf8930 /sys-process/cronbase
parentapp-emulation/qemu: sync readme #575326 and gbm updates #590230 (diff)
downloadgentoo-b11e8d8b4555479dce4054aca1feffb06c0066e6.tar.gz
gentoo-b11e8d8b4555479dce4054aca1feffb06c0066e6.tar.bz2
gentoo-b11e8d8b4555479dce4054aca1feffb06c0066e6.zip
sys-process/cronbase: fix non-POSIX shell code #595492
Diffstat (limited to 'sys-process/cronbase')
-rw-r--r--sys-process/cronbase/cronbase-0.3.7-r6.ebuild (renamed from sys-process/cronbase/cronbase-0.3.7-r5.ebuild)0
-rwxr-xr-xsys-process/cronbase/files/run-crons-0.3.713
2 files changed, 12 insertions, 1 deletions
diff --git a/sys-process/cronbase/cronbase-0.3.7-r5.ebuild b/sys-process/cronbase/cronbase-0.3.7-r6.ebuild
index d263aeb11e0e..d263aeb11e0e 100644
--- a/sys-process/cronbase/cronbase-0.3.7-r5.ebuild
+++ b/sys-process/cronbase/cronbase-0.3.7-r6.ebuild
diff --git a/sys-process/cronbase/files/run-crons-0.3.7 b/sys-process/cronbase/files/run-crons-0.3.7
index 902794e19e6f..42c88100df1c 100755
--- a/sys-process/cronbase/files/run-crons-0.3.7
+++ b/sys-process/cronbase/files/run-crons-0.3.7
@@ -56,7 +56,18 @@ grab_lock() {
# This is better than kill -0 because we can verify that it's really
# another run-crons process.
- if diff -qs /proc/{${cronpid},$$}/cmdline > /dev/null 2>&1; then
+ # We have to send stderr to /dev/null for two reasons:
+ # - If the process disappears, the cmdline file might not exist.
+ # - The cmdline file contains NUL bytes, but bash-4.4+ warns when
+ # you try to assign NUL bytes to variables.
+ # It'd be nice to not do it for a lot of code, but there's not easy
+ # alternative in shell code. We could `cat | tr`, but that'd waste
+ # a bit more than just a simple cat.
+ if (
+ cmdline1=$(cat "/proc/${cronpid}/cmdline") || :
+ cmdline2=$(cat "/proc/$$/cmdline")
+ [ "${cmdline1}" = "${cmdline2}" ]
+ ) 2>/dev/null ; then
# Whoa, another run-crons is really running.
return 1
fi