Source-Changes-HG archive

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

[src/trunk]: src/etc/root Cleanup the "hup" function - quote properly, and te...



details:   https://anonhg.NetBSD.org/src/rev/020962e99321
branches:  trunk
changeset: 368598:020962e99321
user:      kre <kre%NetBSD.org@localhost>
date:      Thu Jul 21 07:53:28 2022 +0000

description:
Cleanup the "hup" function - quote properly, and test for the pid
file existing (with something in it) before simply using it, so the
error message can be controlled, rather than just sh's cannot open file msg.

diffstat:

 etc/root/dot.shrc |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r bed6729412da -r 020962e99321 etc/root/dot.shrc
--- a/etc/root/dot.shrc Thu Jul 21 07:51:12 2022 +0000
+++ b/etc/root/dot.shrc Thu Jul 21 07:53:28 2022 +0000
@@ -1,10 +1,17 @@
-#      $NetBSD: dot.shrc,v 1.8 2007/11/24 11:14:41 pavel Exp $
+#      $NetBSD: dot.shrc,v 1.9 2022/07/21 07:53:28 kre Exp $
 
 if [ -f /etc/shrc ]; then
        . /etc/shrc
 fi
 
-hup(){ (read pid; kill -HUP $pid) </var/run/$1.pid; }
+hup()
+{
+       test -s "/var/run/$1.pid" || {
+               printf >&2 'No pid file for %s\n' "$1"
+               return 1
+       }
+       { read pid; kill -HUP "$pid"; } <"/var/run/$1.pid"
+}
 
 case "$-" in *i*)
        # interactive mode settings go here



Home | Main Index | Thread Index | Old Index