Prevent .history file corruption
- Implement file locking using shared readers, exclusive writer
to prevent any .history file data corruption
- Handle pending signals before flush so that the the .history file
does not get truncated
Resolves: #653054