Bug #64

bashism in "one" script

Added by soren-ubuntu-com - over 12 years ago. Updated over 12 years ago.

Status:ClosedStart date:
Priority:HighDue date:
Assignee:Ruben S. Montero% Done:

0%

Category:Core & System
Target version:Release 1.2
Resolution:fixed Pull request:
Affected Versions:

Description

The "one" script has a bashism that causes a race condition when /bin/sh isn't bash.

It does this:

kill cat $ONE_PID &> /dev/null
kill 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.

stop-race.patch Magnifier (1.03 KB) soren-ubuntu-com -, 01/17/2009 03:33 PM

Associated revisions

Revision 9afa9596
Added by Ruben S. Montero over 12 years ago

address #64. Patch contributed by soren

git-svn-id: http://svn.opennebula.org/one/trunk@304 3034c82b-c49b-4eb3-8279-a7acafdc01c0

Revision f3332d01
Added by Ruben S. Montero over 12 years ago

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

History

#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

#2 Updated by soren-ubuntu-com - over 12 years ago

Yes, that's the strict posix shell version. I didn't know that was what it did in bash :) Glad I could help!

#3 Updated by Ruben S. Montero over 12 years ago

  • Status changed from New to Closed
  • Resolution set to fixed

I've committed the patch to the trunk r304 , and to the 1.2 branch r305

Also available in: Atom PDF