pub_filelock.c

来自「自已结累的Unix下C语言开发函数库」· C语言 代码 · 共 41 行

C
41
字号
/* *文件锁定的一些函数 *zyq - shilyu - cff 040908 *functionnum 002 */ #include "./../inc/pub.h"#if !defined( DEBUG )#define DEBUG#endif/* 001  *文件上锁(System V咨询锁) */int lm_lock( int fd ) {	lseek( fd, 0L, SEEK_SET ) ;	if( lockf( fd, F_LOCK, 0L ) == -1 ) 	{		perror( "can not F_LOCK" ) ;		return 1 ;	}		return 0 ;}/* 002 *文件解锁(System V咨询锁) */int lm_unlock( int fd ) {	lseek( fd, 0L, 0 ) ;	if( lockf( fd, F_ULOCK, 0L ) == -1 ) 	{		perror( "can not F_ULOCK" ) ;		return 1 ;	}	return 0 ;}

⌨️ 快捷键说明

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