bashism in "one" script
|Assignee:||Ruben S. Montero||% Done:|
|Category:||Core & System|
|Target version:||Release 1.2|
The "one" script has a bashism that causes a race condition when /bin/sh isn't bash.
It does this:
cat $ONE_PID &> /dev/null
cat $ONE_SCHEDPID &> /dev/null
...and removes the PID files immediately afterwards.
"foo &> bar" in bash is equivalent to "foo > bar", but in dash, it's equivalent to "foo > bar &", so "kill" and "rm" race to get to the PID file first. Every once in a while, rm wins and you get something like:
kill: 147: Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or
kill -l [exitstatus]
..and either the scheduler or oned is still running.
The attached patch fixes this problem.
backport of patch for #64 to the 1.2 branch
git-svn-id: http://svn.opennebula.org/one/branches/one-1.2@305 3034c82b-c49b-4eb3-8279-a7acafdc01c0
#1 Updated by Ruben S. Montero over 12 years ago
Yes I've experimented this bug sometimes also, and I did not have a clue of where it comes form. THANKS for this one! :D.
Just to make sure, if we want to preserve the bash semantics i.e. redirect both stdout and stderr, will the following work both in dash and bash?:
kill cat $ONE_PID > /dev/null 2>&1