Index: head/etc/rc.d/savecore =================================================================== --- head/etc/rc.d/savecore +++ head/etc/rc.d/savecore @@ -70,7 +70,7 @@ if savecore -C "${dev}" >/dev/null; then savecore ${savecore_flags} ${dumpdir} ${dumpdev} if checkyesno crashinfo_enable; then - ${crashinfo_program} -d ${dumpdir} + ${crashinfo_program} -b -d ${dumpdir} fi sync else Index: head/usr.sbin/crashinfo/crashinfo.8 =================================================================== --- head/usr.sbin/crashinfo/crashinfo.8 +++ head/usr.sbin/crashinfo/crashinfo.8 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 28, 2008 +.Dd April 19, 2017 .Dt CRASHINFO 8 .Os .Sh NAME @@ -88,6 +88,12 @@ .Pp The options are as follows: .Bl -tag -width indent +.It Fl b +Run in batch mode. Write most messages to the +.Pa core.txt.XX +file instead of the terminal. This flag is used when +.Nm +is run during boot. .It Fl d Ar crashdir Specify an alternate core dump directory. The default crash dump directory is Index: head/usr.sbin/crashinfo/crashinfo.sh =================================================================== --- head/usr.sbin/crashinfo/crashinfo.sh +++ head/usr.sbin/crashinfo/crashinfo.sh @@ -31,7 +31,8 @@ usage() { - echo "usage: crashinfo [-d crashdir] [-n dumpnr] [-k kernel] [core]" + echo "usage: crashinfo [-b] [-d crashdir] [-n dumpnr]" \ + "[-k kernel] [core]" exit 1 } @@ -93,12 +94,16 @@ done } +BATCH=false CRASHDIR=/var/crash DUMPNR= KERNEL= -while getopts "d:n:k:" opt; do +while getopts "bd:n:k:" opt; do case "$opt" in + b) + BATCH=true + ;; d) CRASHDIR=$OPTARG ;; @@ -153,6 +158,11 @@ FILE=$CRASHDIR/core.txt.$DUMPNR HOSTNAME=`hostname` +if $BATCH; then + echo "Writing crash summary to $FILE." + exec > $FILE 2>&1 +fi + find_gdb if [ -z "$GDB" ]; then echo "Unable to find a kernel debugger." @@ -181,8 +191,6 @@ exit 1 fi -echo "Writing crash summary to $FILE." - umask 077 # Simulate uname @@ -191,7 +199,10 @@ version=$(gdb_command $KERNEL 'printf "%s", version' | tr '\t\n' ' ') machine=$(gdb_command $KERNEL 'printf "%s", machine') -exec > $FILE 2>&1 +if ! $BATCH; then + echo "Writing crash summary to $FILE." + exec > $FILE 2>&1 +fi echo "$HOSTNAME dumped core - see $VMCORE" echo