OS Xがロックメカニズムをどのように実装しているかわからないので、この質問に対する答えは本当にわかりません。
マンページに記載されているPOSIXアドバイザリロックを使用する場合があります。もし私があなたなら、Finder内から作成したアドバイザリロックについて(マンページ)がどう思うかを示すために、Cで1031行のテストプログラムを作成します。flock()
fcntl()
(未テスト)のようなもの:
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
int main(int argc, const char **argv)
{
for (int i = 1; i < argc; i++)
{
const char *filename = argv[i];
int fd = open(filename, O_RDONLY);
if (fd >= 0)
{
struct flock flock;
if (fcntl(fd, F_GETLK, &flock) < 0)
{
fprintf(stderr, "Failed to get lock info for '%s': %s\n", filename, strerror(errno));
}
else
{
// Possibly print out other members of flock as well...
printf("l_type=%d\n", (int)flock.l_type);
}
close(fd);
}
else
{
fprintf(stderr, "Failed to open '%s': %s\n", filename, strerror(errno));
}
}
return 0;
}