📄 lock.c
字号:
#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include "apue.h"void initlock(const char *lockfile){ int i; unlink(lockfile);}void lock(const char *lockfile){ int fd; while ( (fd = open(lockfile, O_RDONLY | O_CREAT | O_EXCL, FILE_MODE)) < 0) sleep(1); close(fd);}void unlock(const char *lockfile){ unlink(lockfile);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -