lockf.c
来自「早期freebsd实现」· C语言 代码 · 共 28 行
C
28 行
#include <sys/types.h>/* * Include <sys/file.h>, not <fcntl.h>, the flock(2) * #defines were found there on historical systems. */#include <sys/file.h>#include <errno.h>#include <unistd.h>#include <compat.h>/* * Use lockf(2) locking to fake flock(2) locking. */intflock(fd, operation) int fd, operation;{ if (!lockf(fd, operation & LOCK_UN ? F_ULOCK : operation & LOCK_NB ? F_TLOCK : F_LOCK, 0)) return (0); if (errno == EACCES || errno == EAGAIN) errno = EWOULDBLOCK; return (-1);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?