Update ReplxxLineReader.cpp

This commit is contained in:
alexey-milovidov 2020-06-06 12:49:15 +03:00 committed by GitHub
parent d0312bf1fe
commit 7003fe8258
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,26 +26,28 @@ ReplxxLineReader::ReplxxLineReader(
if (!history_file_path.empty())
{
errno = 0;
history_file_fd = open(history_file_path.c_str(), O_RDWR);
if (history_file_fd < 0)
{
rx.print("Open of history file failed: %s\n", strerror(errno));
}
errno = 0;
else
{
if (flock(history_file_fd, LOCK_SH))
{
rx.print("Shared lock of history file failed: %s\n", strerror(errno));
}
else
{
rx.history_load(history_file_path);
errno = 0;
if (flock(history_file_fd, LOCK_UN))
{
rx.print("Unlock of history file failed: %s\n", strerror(errno));
}
}
}
}
auto callback = [&suggest] (const String & context, size_t context_size)
{