[질문] open 시 배타적열기에 대해서..??

dorijjang의 이미지

안녕하세요~^^
open 함수에 대해서 TEST 중 이상점이 발견되어 이렇게 질문드립니다.

open 함수에서 flag에서 O_EXCL 옵션에 대한 질문인데요,
책에 나와있기로는 이 옵션을 체크하였을 경우
오직 한번에 한 프로세스만이 파일을 생성할 수 있음을 보장한다고 나와있는데요,

TEST 중 별개의 프로세스가 동일 화일을 생성하는것을 보았습니다.
이러면 안되는데 말이죠? ㅡㅡ)?

네, 질문의 요점은
O_EXCL 사용시 오직 한번에 한 프로세스만이 파일을 생성하는것인가요?

그럼, 답변주시면 정말정말 감사드리겠습니다.
즐거운 하루 되세요~^^

익명 사용자의 이미지

     O_EXCL
           If O_CREAT and O_EXCL are set,  open()  fails  if  the
           file  exists.  The check for the existence of the file
           and the creation of the file if it does not  exist  is
           atomic  with  respect  to  other  processes  executing
           open() naming the same filename in the same  directory
           with  O_EXCL  and  O_CREAT set. If O_CREAT is not set,
           the effect is undefined.

솔라리스 open(2) 맨페이지의 일부입니다.

O_EXCL은 O_CREAT와 함께 써야한다고 되어있네요.