From 36b190a918a293c5c73d40f171ad0fe903045d2d Mon Sep 17 00:00:00 2001 From: Darafei Praliaskouski Date: Fri, 8 May 2026 01:37:10 +0400 Subject: [PATCH] fix(cmdpipe): clarify mtr-packet startup failures --- ui/cmdpipe.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/cmdpipe.c b/ui/cmdpipe.c index bd5606a..73b868d 100644 --- a/ui/cmdpipe.c +++ b/ui/cmdpipe.c @@ -100,10 +100,15 @@ int send_synchronous_command( if (read_length < 0) { return -1; } + if (read_length == 0) { + errno = EPIPE; + return -1; + } /* Parse the query reply */ reply[read_length] = 0; if (parse_command(result, reply)) { + errno = EPROTO; return -1; } @@ -205,6 +210,17 @@ int check_packet_features( } +static +void fail_packet_startup( + int saved_errno) +{ + error(0, saved_errno, "Failure to start mtr-packet"); + error(EXIT_FAILURE, 0, + "mtr-packet did not answer the startup check; " + "check that it is installed and allowed to open probe sockets"); +} + + extern char *myname; /* Execute mtr-packet, allowing the MTR_PACKET environment to override @@ -313,7 +329,7 @@ int open_command_pipe( execute the mtr-packet binary, we will discover that here. */ if (check_feature(ctl, cmdpipe, "send-probe")) { - error(EXIT_FAILURE, errno, "Failure to start mtr-packet"); + fail_packet_startup(errno); } if (check_packet_features(ctl, cmdpipe)) { -- 2.47.3