MFC r345318:

lockf(1): return EX_UNAVAILABLE if -n is used and the lock file does not
exist

Apply EX_UNAVAILABLE patch part from PR 170775 to match the documentation.

Was checked with a command from PR 210770:
lockf -n /tmp/doesnotexist echo; echo $?

PR:		210770
This commit is contained in:
Andriy Voskoboinyk committed 2019-03-27 08:55:59 +00:00
1 parent be65c0eac9
commit 7f14ada8a7
1 file changed
+2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/11/; revision=345569
+2
View File
@@ -174,6 +174,8 @@ acquire_lock(const char *name, int flags)
if ((fd = open(name, O_RDONLY|O_EXLOCK|flags, 0666)) == -1) {
if (errno == EAGAIN || errno == EINTR)
return (-1);
else if (errno == ENOENT && (flags & O_CREAT) == 0)
err(EX_UNAVAILABLE, "%s", name);
err(EX_CANTCREAT, "cannot open %s", name);
}
return (fd);