From 41263cf8c94c1b9bab8e27c4c830dc6cdd605297 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 15 Nov 2015 08:40:36 +0100 Subject: [PATCH] scripts/savecore: Report nicely when there's no core dump 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 --- scripts/savecore | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/savecore b/scripts/savecore index e2b2ae0fe..becd752cf 100755 --- a/scripts/savecore +++ b/scripts/savecore @@ -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` -- 2.43.0