当前位置: 代码迷 >> 综合 >> open中O_EXCL选项的介绍与分析
  详细解决方案

open中O_EXCL选项的介绍与分析

热度:30   发布时间:2024-01-16 14:40:32.0

open的man中的介绍:

O_EXCL
              Ensure  that  this  call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail.  The behavior of O_EXCL is undefined if O_CREAT is not specified.
 
              When these two flags are specified, symbolic links are not followed: if pathname is a symbolic link, then open() fails regardless of where the symbolic link points to.
 
              O_EXCL is only supported on NFS when using NFSv3 or later on kernel 2.6 or later.  In environments where NFS O_EXCL support is not provided, programs that rely on it for performing locking tasks will contain a race  condition.   Portable  programs  that want  to  perform  atomic  file  locking  using a lockfile, and need to avoid reliance on NFS support for O_EXCL, can create a unique file on the same file system (e.g., incorporating hos
  相关解决方案