git: 8c20260bc55d - main - bhyveload: do not hang on EOF from console input

From: Roman Bogorodskiy <novel_at_FreeBSD.org>
Date: Sat, 19 Sep 2026 08:28:01 UTC
The branch main has been updated by novel:

URL: https://cgit.FreeBSD.org/src/commit/?id=8c20260bc55d7b4be0cbcf0a940505ae15ab41a9

commit 8c20260bc55d7b4be0cbcf0a940505ae15ab41a9
Author:     Roman Bogorodskiy <novel@FreeBSD.org>
AuthorDate: 2026-08-27 17:40:43 +0000
Commit:     Roman Bogorodskiy <novel@FreeBSD.org>
CommitDate: 2026-09-19 07:39:49 +0000

    bhyveload: do not hang on EOF from console input
    
    Currently, when bhyveload(8) fails to boot the guest,
    it drops into the loader prompt waiting for user input.
    
    This behaviour is inconvenient when using bhyveload(8) from
    scripts.
    
    Make it exit when it receives EOF from console input.
    
    PR:             286289
    Reviewed by:    markj
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D59226
---
 usr.sbin/bhyveload/bhyveload.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
index 5cf05b97a00c..154afd4ce398 100644
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -135,8 +135,12 @@ static int
 cb_getc(void *arg __unused)
 {
 	char c;
+	ssize_t nread;
 
-	if (read(consin_fd, &c, 1) == 1)
+	nread = read(consin_fd, &c, 1);
+	if (nread == 0)
+		cb_exit(NULL, USERBOOT_EXIT_QUIT);
+	if (nread == 1)
 		return (c);
 	return (-1);
 }