Detecting that log file has been deleted or truncated on POSIX systems?

后端 未结 5 1331
难免孤独
难免孤独 2021-01-13 22:11

Suppose a long-running process writes to a log file. Suppose that log file is kept open indefinitely. Suppose that a careless system administrator deletes that log file.

5条回答
  •  青春惊慌失措
    2021-01-13 22:46

    When a file is closed the modification time is changed. So check periodically on the mtime using stat() will work.

提交回复
热议问题