Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/ldd Return a non-zero (one) exit code on failure for...



details:   https://anonhg.NetBSD.org/src/rev/ed5eb9013a3d
branches:  trunk
changeset: 828659:ed5eb9013a3d
user:      maya <maya%NetBSD.org@localhost>
date:      Mon Dec 25 05:08:49 2017 +0000

description:
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

diffstat:

 usr.bin/ldd/ldd.1 |   6 ++++--
 usr.bin/ldd/ldd.c |  13 ++++++++-----
 2 files changed, 12 insertions(+), 7 deletions(-)

diffs (79 lines):

diff -r 9fd7bc6e6263 -r ed5eb9013a3d usr.bin/ldd/ldd.1
--- a/usr.bin/ldd/ldd.1 Mon Dec 25 04:41:48 2017 +0000
+++ b/usr.bin/ldd/ldd.1 Mon Dec 25 05:08:49 2017 +0000
@@ -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 @@
 .Nm
 behave analogously to
 .Ic nm Fl o .
+.Sh EXIT STATUS
+.Ex -std
 .Sh SEE ALSO
 .Xr ld 1 ,
 .Xr ld.elf_so 1 ,
diff -r 9fd7bc6e6263 -r ed5eb9013a3d usr.bin/ldd/ldd.c
--- a/usr.bin/ldd/ldd.c Mon Dec 25 04:41:48 2017 +0000
+++ b/usr.bin/ldd/ldd.c Mon Dec 25 05:08:49 2017 +0000
@@ -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 @@
 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 @@
 
                fd = open(*argv, O_RDONLY);
                if (fd == -1) {
+                       exit_status = EXIT_FAILURE;
                        warn("%s", *argv);
                        continue;
                }
@@ -171,12 +172,14 @@
                    && 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;
 }
 
 /*



Home | Main Index | Thread Index | Old Index