From 7e99c034f788128c7d168eaf27af9a3acaa06163 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 20 Jan 2021 09:54:46 +0000 Subject: [PATCH] Emit uprintf() output for initproc if there is no controlling terminal This patch helped me debug why /sbin/init was not being loaded after making changes to the image activator in CheriBSD. Reviewed By: jhb (earlier version), kib Differential Revision: https://reviews.freebsd.org/D28121 --- sys/kern/subr_prf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 31117c4e341..b51213a25d0 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -179,6 +179,14 @@ uprintf(const char *fmt, ...) if (TD_IS_IDLETHREAD(td)) return (0); + if (td->td_proc == initproc) { + /* Produce output when we fail to load /sbin/init: */ + va_start(ap, fmt); + retval = vprintf(fmt, ap); + va_end(ap); + return (retval); + } + sx_slock(&proctree_lock); p = td->td_proc; PROC_LOCK(p);