linux下C语言中的flock函数用法

先贴出来flock在man页下的解释FLOCK(2)                   Linux Programmer’s Manual                  FLOCK(2)NAME       flock - apply or remove an advisory lock on an open fileSYNOPSIS       #include        int flock(int fd, int operation);DESCRIPTION    
摘要由CSDN通过智能技术生成

先贴出来flock在man页下的解释

FLOCK(2)                   Linux Programmer’s Manual                  FLOCK(2)
NAME
       flock - apply or remove an advisory lock on an open file
SYNOPSIS
       #include <sys/file.h>
       int flock(int fd, int operation);
DESCRIPTION
       Apply or remove an advisory lock on the open file specified by fd.  The parameter operation is one of the following:
              LOCK_SH   Place a shared lock.  More than one process may hold a shared lock for a given file at a given time.
              LOCK_EX   Place  an exclusive lock.  Only one process may hold an exclusive lock for a given file at a given time.
              LOCK_UN   Remove an existing lock held by this process.
       A call to flock() may block if an incompatible lock is held by another process.  To make a non-blocking request,  include
       LOCK_NB (by ORing) with any of the above operations.
       A single file may not simultaneously have both shared and exclusive locks.
       Locks  created by flock() are associated with an open file table entry.  This means that duplicate file descriptors (created by, for example, fork(2) or dup(2)) refer to the same lock, and this lock may be modified or released using  any  of
       these  descriptors.   Furthermore, the lock is released either by an explicit LOCK_UN oper

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值