From cd21bf5152aa75fa8a13091c4ba85f3c16b9d1a9 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 4 Oct 1999 21:26:11 +0000 Subject: If we can't chdir to the root dir in -execdir, just return instead of generating an error. Most times this is just because the target is not a directory. Also close an fd leak introduced in the last commit. --- usr.bin/find/function.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 80b8e6e9003..f69043ec695 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1,4 +1,4 @@ -/* $OpenBSD: function.c,v 1.15 1999/10/04 21:17:32 millert Exp $ */ +/* $OpenBSD: function.c,v 1.16 1999/10/04 21:26:10 millert Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -38,7 +38,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)function.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: function.c,v 1.15 1999/10/04 21:17:32 millert Exp $"; +static char rcsid[] = "$OpenBSD: function.c,v 1.16 1999/10/04 21:26:10 millert Exp $"; #endif /* not lint */ #include @@ -453,7 +453,7 @@ f_execdir(plan, entry) return (0); } if (chdir(entry->fts_accpath)) { - warn("cannot chdir to %s", entry->fts_accpath); + (void) close(fd); return (0); } } @@ -484,8 +484,10 @@ f_execdir(plan, entry) if (entry->fts_level == FTS_ROOTLEVEL) { if (fchdir(fd) == -1) { warn("unable to chdir back to starting directory"); + (void) close(fd); return (0); } + (void) close(fd); } pid = waitpid(pid, &status, 0); -- cgit v1.2.3