To avoid data crupption, we use a read-write lock to ensure that data modification is exclusive. But when a program is writting data when something bad, for example, a SIGKILL, happens that crashes the program before the write operation is complete and lock is released, other processes may not be able to enter the exclusive region again. I do not use an auto recovery lock such as flock, which will automatically release when process exits, just in case that wrong data is returned when performing a reading operation, or even, causing a segment fault.
我看到描述中,进程退出是不能释放锁的,但看到代码实现中使用的是flock,是这样吗?