]> git.pond.sub.org Git - empserver/commitdiff
scripts/savecore: Report nicely when there's no core dump
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 15 Nov 2015 07:40:36 +0000 (08:40 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 5 Dec 2015 12:19:38 +0000 (13:19 +0100)
When savecore can't find a core dump, it reports something like

    ls: cannot access core.*: No such file or directory

to stderr, and fails.  If privlog is set, it also mails out a "Could
not save core dump" note.

Suppress the error message, and mail out "Could not find core dump to
save" instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
scripts/savecore

index e2b2ae0feee966f9e44ce0f6bc7b717283f038a0..becd752cfe0798b384b2963ae9a307835ed30a0e 100755 (executable)
@@ -41,20 +41,23 @@ mailx=mailx
 # End of configuration
 
 saved=
+core_name=
 
 alert_deity ()
 {
     local msg;
     if [ "$saved" ]
     then msg="Core dump $saved_core saved."
-    else msg="Could not save core dump."
+    elif [ "$core_name" ]
+    then msg="Could not save core dump $core_name."
+    else msg="Could not find core dump to save."
     fi
-    echo $msg | $mailx -s "emp_server dumped core in $PWD" "$privlog"
+    echo "$msg" | $mailx -s "emp_server dumped core in $PWD" "$privlog"
 }
 
 test -n "$privlog" && trap 'alert_deity' EXIT
 
-core_name=`ls -td $core_pattern | head -n 1`
+core_name=`ls -td $core_pattern 2>/dev/null | head -n 1`
 test -n "$core_name"
 test -r "$core_name"
 tstamp=`/bin/date +%Y-%m-%d-%H:%M`