⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 locktest.c

📁 该压缩文件为unix环境高级编程这本书所附带的源码,希望有人需要!
💻 C
字号:
#include "apue.h"#include <fcntl.h>pid_tlock_test(int fd, int type, off_t offset, int whence, off_t len){	struct flock	lock;	lock.l_type = type;		/* F_RDLCK or F_WRLCK */	lock.l_start = offset;	/* byte offset, relative to l_whence */	lock.l_whence = whence;	/* SEEK_SET, SEEK_CUR, SEEK_END */	lock.l_len = len;		/* #bytes (0 means to EOF) */	if (fcntl(fd, F_GETLK, &lock) < 0)		err_sys("fcntl error");	if (lock.l_type == F_UNLCK)		return(0);		/* false, region isn't locked by another proc */	return(lock.l_pid);	/* true, return pid of lock owner */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -