sys-process/cronbase: More fixes
authorTobias Klausmann <klausman@gentoo.org>
Sun, 2 Oct 2016 08:46:32 +0000 (10:46 +0200)
committerTobias Klausmann <klausman@gentoo.org>
Sun, 2 Oct 2016 08:48:39 +0000 (10:48 +0200)
The tr approach is racy, even with the test -r before it. Since tr can't
be told to read from a file and we can't redirect the subshell's warning
message, switch to sed and a file argument, then redirect stderr of
that.

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

index ce8ff76e98bb2773f2414f3cfa870aa325729878..958ef06c1ef728f13a1a4848372c37217969dc9b 100755 (executable)
@@ -58,8 +58,8 @@ grab_lock() {
                # another run-crons process.
                # The tr call deletes null bytes so newer bash versions do not complain
                # about them.
-               cmdline1=$([ -r "/proc/${cronpid}/cmdline" ] && tr -d '\0'  < "/proc/${cronpid}/cmdline" 2>/dev/null) || :
-               cmdline2=$(tr -d '\0'  < /proc/$$/cmdline)
+               cmdline1=$(sed -e 's/\0/ /g' "/proc/${cronpid}/cmdline" 2>/dev/null) || :
+               cmdline2=$(sed -e 's/\0/ /g' /proc/$$/cmdline)
                if [ "${cmdline1}" = "${cmdline2}" ] ; then
                        # Whoa, another run-crons is really running.
                        return 1