From 895672953e6f7e8b88a42701e80873afbe159d2e Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Fri, 27 Jun 2014 12:02:07 -0500 Subject: [PATCH] kpatch-build: detect core dump --- kpatch-build/kpatch-build | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 29a830e..4335a77 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -50,11 +50,15 @@ TEMPDIR= APPLIEDPATCHFILE="kpatch.patch" DEBUG=0 +warn() { + echo "ERROR: $1" >&2 +} + die() { if [[ -z $1 ]]; then - echo "ERROR: kpatch build failed. Check $LOGFILE for more details." >&2 + warn "kpatch build failed. Check $LOGFILE for more details." else - echo "ERROR: $1" >&2 + warn "$1" fi exit 1 } @@ -196,7 +200,7 @@ while [[ $# -gt 0 ]]; do ;; --) if [[ -z "$2" ]]; then - echo "ERROR: no patch file specified" >&2 + warn "no patch file specified" usage exit 1 fi @@ -407,7 +411,18 @@ for i in $FILES; do debugopt= [[ $DEBUG -eq 1 ]] && debugopt=-d "$TOOLSDIR"/create-diff-object $debugopt "orig/$i" "patched/$i" "$KOBJFILE" "output/$i" 2>&1 |tee -a "$LOGFILE" - [[ "${PIPESTATUS[0]}" -eq 0 ]] || die + rc="${PIPESTATUS[0]}" + if [[ $rc = 139 ]]; then + warn "create-diff-object SIGSEGV" + if ls core* &> /dev/null; then + cp core* /tmp + warn "core file at /tmp/$(ls core*)" + else + warn "no core file found, run 'ulimit -c unlimited' and try to recreate" + fi + exit 1 + fi + [[ $rc -eq 0 ]] || die done echo -n "Patched objects:"