aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorBill Fenner <fenner@FreeBSD.org>2002-11-30 23:12:59 +0000
committerBill Fenner <fenner@FreeBSD.org>2002-11-30 23:12:59 +0000
commit01e7d8319d5afb5ed0fe184f9c24260377773cb9 (patch)
tree1368310523ab417b48d95a94bcc869840d8cd972 /usr.bin
parentb103cd4113dc4c57443ada9c149156edd670dd53 (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xinstall/xinstall.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index ca30c3497688c..cc27f6e7ec944 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -598,6 +598,8 @@ int
create_newfile(const char *path, int target, struct stat *sbp)
{
char backup[MAXPATHLEN];
+ int saved_errno = 0;
+ int newfd;
if (target) {
/*
@@ -621,10 +623,14 @@ create_newfile(const char *path, int target, struct stat *sbp)
if (rename(path, backup) < 0)
err(EX_OSERR, "rename: %s to %s", path, backup);
} else
- (void)unlink(path);
+ if (unlink(path) < 0)
+ saved_errno = errno;
}
- return (open(path, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR));
+ newfd = open(path, O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR);
+ if (newfd < 0 && saved_errno != 0)
+ errno = saved_errno;
+ return newfd;
}
/*