diff --git a/src/util/src/tlog.c b/src/util/src/tlog.c index 47521fc36e594b9f4bfde1171c5cfdb0831a9e2e..01a0eabbca39258951f2e0d6c4e098c7bf009be8 100644 --- a/src/util/src/tlog.c +++ b/src/util/src/tlog.c @@ -191,15 +191,14 @@ void taosResetLog() { } static bool taosCheckFileIsOpen(char *logFileName) { - int32_t exist = access(logFileName, F_OK); - if (exist != 0) { - return false; - } - - int32_t fd = open(logFileName, O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); + int32_t fd = open(logFileName, O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO); if (fd < 0) { - printf("\nfailed to open log file:%s, reason:%s\n", logFileName, strerror(errno)); - return true; + if (errno == ENOENT) { + return false; + } else { + printf("\nfailed to open log file:%s, reason:%s\n", logFileName, strerror(errno)); + return true; + } } if (taosLockFile(fd)) {