Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yeah, it requires OS support, but it's no different than most of the standard library. Opening files, writing to files, printing to the console, allocating memory, etc. all require OS support, too.

As to how it can be implemented, "man 2 open" on OSX shows O_EXLOCK and O_SHLOCK flags, and they're from BSD. Not sure if they're POSIX, but I'd bet Linux has something equivalent. And there's also the flock() function. My guess is the new "x" option to fopen can be implemented using O_EXLOCK and flock(), though I'm too tired to look up details on how it could be done.



It should be just O_EXCL, which is POSIX.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: