if (pfxlen <= 1)
rc = EINVAL;
else {
- int infd = open(filename, O_RDWR | O_CREAT, fmode);
+ int infd = open(filename, O_RDWR | O_CREAT | O_EXLOCK, fmode);
if (infd == -1)
rc = errno;
strcpy(file, filename);
strcat(file, ".new");
- outfd = open(file, O_RDWR | O_CREAT | O_TRUNC | O_EXLOCK, fmode);
+ outfd = open(file, O_RDWR | O_CREAT | O_TRUNC, fmode);
if (outfd == -1)
rc = errno;
else {
* to 'file'.
* This is a gross hack, but we may have
* corrupted the original file
- * Unfortunately, it will lose the inode
- * and hence the lock.
*/
if (fflush(infp) == EOF || ferror(infp))
rename(file, filename);