In my uderstanding, I should make the writing an atomic operation.

pasu (InTheSky)
So I should use some lock, or say log. And I should put this lock on the disk because after the process die there is nothing leave in memory. So I will try to write a log which content is the position I wrote in the working file. Every time before I write something to the working file, I will write the position into the log file. After the working file is closed, the log file should be empty. And every time when the program restart, it will check the log file first. If there is something in the log file, pick up the last position and begin the writing from the next position.

In fact what I said is something like the logical log in RDBMS. Is it ok?
2001-4-12 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: 请教大家一个技术问题, UNIX系统下, 如何写一个C程序, 能够在异常中断后程序重启时自动恢复文件读写指针(即接着上次中断的断点接着读写).

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论