Add .history file locking - shared readers, exclusive writer

Originally reported at Red Hat Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=648592

Patch by Vojtech Vitek (V-Teq) <vvitek@redhat.com>