Return a non-zero (one) exit code on failure for one of the files

But keep on processing them, like ls, rm, and other programs do
This commit is contained in:
maya 2017-12-25 05:08:49 +00:00
parent d6af4f8075
commit 47dee010ce
2 changed files with 12 additions and 7 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ldd.1,v 1.19 2017/07/03 21:34:19 wiz Exp $
.\" $NetBSD: ldd.1,v 1.20 2017/12/25 05:08:49 maya Exp $
.\"
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd September 7, 2009
.Dd December 25, 2017
.Dt LDD 1
.Os
.Sh NAME
@ -105,6 +105,8 @@ which makes
.Nm
behave analogously to
.Ic nm Fl o .
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
.Xr ld 1 ,
.Xr ld.elf_so 1 ,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ldd.c,v 1.22 2014/03/02 03:55:19 matt Exp $ */
/* $NetBSD: ldd.c,v 1.23 2017/12/25 05:08:49 maya Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ldd.c,v 1.22 2014/03/02 03:55:19 matt Exp $");
__RCSID("$NetBSD: ldd.c,v 1.23 2017/12/25 05:08:49 maya Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -122,7 +122,7 @@ int
main(int argc, char **argv)
{
const char *fmt1 = NULL, *fmt2 = NULL;
int c;
int c, exit_status = EXIT_SUCCESS;
#ifdef DEBUG
debug = 1;
@ -160,6 +160,7 @@ main(int argc, char **argv)
fd = open(*argv, O_RDONLY);
if (fd == -1) {
exit_status = EXIT_FAILURE;
warn("%s", *argv);
continue;
}
@ -171,12 +172,14 @@ main(int argc, char **argv)
&& elf32_ldd_compat(fd, *argv, fmt1, fmt2) == -1
#endif
#endif
)
) {
exit_status = EXIT_FAILURE;
warnx("%s", error_message);
}
close(fd);
}
return 0;
return exit_status;
}
/*