Source-Changes-HG archive

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

[src/trunk]: src/etc print human readable exit code.



details:   https://anonhg.NetBSD.org/src/rev/5204d17a82cc
branches:  trunk
changeset: 755408:5204d17a82cc
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jun 04 18:42:54 2010 +0000

description:
print human readable exit code.

diffstat:

 etc/rc      |   4 ++--
 etc/rc.subr |  20 +++++++++++++++++++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diffs (52 lines):

diff -r 802ce5800b54 -r 5204d17a82cc etc/rc
--- a/etc/rc    Fri Jun 04 18:42:32 2010 +0000
+++ b/etc/rc    Fri Jun 04 18:42:54 2010 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: rc,v 1.164 2009/09/11 18:17:04 apb Exp $
+# $NetBSD: rc,v 1.165 2010/06/04 18:42:54 christos Exp $
 #
 # rc --
 #      Run the scripts in /etc/rc.d with rcorder, and log output
@@ -270,7 +270,7 @@
                # If the command failed, report it, and add it to a list.
                if [ "$2" != 0 ]; then
                        rc_failures="${rc_failures}${rc_failures:+ }$1"
-                       msg="$1 reported failure status $2"
+                       msg="$1 $(human_exit_code $2)"
                        rc_log_message "$msg"
                        if ! $rc_silent; then
                                printf "%s\n" "$msg"
diff -r 802ce5800b54 -r 5204d17a82cc etc/rc.subr
--- a/etc/rc.subr       Fri Jun 04 18:42:32 2010 +0000
+++ b/etc/rc.subr       Fri Jun 04 18:42:54 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.81 2010/03/15 18:59:47 jmmv Exp $
+# $NetBSD: rc.subr,v 1.82 2010/06/04 18:42:54 christos Exp $
 #
 # Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1175,4 +1175,22 @@
        _twiddle_state="$_next"
 }
 
+#
+# human_exit_code
+#      Print the a human version of the exit code.
+#
+human_exit_code()
+{
+       if [ $1 -lt 127 ]
+       then
+               echo "exited with code $1"
+       elif [ $1 -eq 127 ]
+       then
+               echo "stopped with signal $(expr $1 / 256)"
+       else
+               echo "terminated with signal $(expr $1 - 128)"
+       fi
+}
+       
+
 _rc_subr_loaded=:



Home | Main Index | Thread Index | Old Index