sys-process/cronbase: Fix the parall-job check once and for all.
authorTobias Klausmann <klausman@gentoo.org>
Mon, 3 Oct 2016 17:17:57 +0000 (19:17 +0200)
committerTobias Klausmann <klausman@gentoo.org>
Mon, 3 Oct 2016 17:19:08 +0000 (19:19 +0200)
Thanks to Dan Goodliffe for suggesting this approach.

Gentoo-Bug: 595492

sys-process/cronbase/cronbase-0.3.7-r5.ebuild [moved from sys-process/cronbase/cronbase-0.3.7-r4.ebuild with 100% similarity]
sys-process/cronbase/files/run-crons-0.3.7

index 958ef06c1ef728f13a1a4848372c37217969dc9b..902794e19e6f744bb7aa9f928e5ee4d61e39ac3b 100755 (executable)
@@ -56,11 +56,7 @@ grab_lock() {
 
                # This is better than kill -0 because we can verify that it's really
                # another run-crons process.
-               # The tr call deletes null bytes so newer bash versions do not complain
-               # about them.
-               cmdline1=$(sed -e 's/\0/ /g' "/proc/${cronpid}/cmdline" 2>/dev/null) || :
-               cmdline2=$(sed -e 's/\0/ /g' /proc/$$/cmdline)
-               if [ "${cmdline1}" = "${cmdline2}" ] ; then
+               if diff -qs /proc/{${cronpid},$$}/cmdline > /dev/null 2>&1; then
                        # Whoa, another run-crons is really running.
                        return 1
                fi