From ab1ad50d8022978012ec6f54d07b9e7d9eab599e Mon Sep 17 00:00:00 2001 From: mlelstv Date: Fri, 26 Jan 2024 07:10:04 +0000 Subject: [PATCH] Don't use the signal handler to terminate when nothing is to do (count=0, files=0). The signal handler tries to raise the signal again, so that a parent can retrieve the signal from the exit code. Calling the terminate handler with signal code 0 doesn't raise a signal and dd continues with exit(127) making this case an error. --- bin/dd/args.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/dd/args.c b/bin/dd/args.c index a6612702fea4..c3bb645ef9e6 100644 --- a/bin/dd/args.c +++ b/bin/dd/args.c @@ -1,4 +1,4 @@ -/* $NetBSD: args.c,v 1.42 2022/01/14 23:55:16 christos Exp $ */ +/* $NetBSD: args.c,v 1.43 2024/01/26 07:10:04 mlelstv Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: args.c,v 1.42 2022/01/14 23:55:16 christos Exp $"); +__RCSID("$NetBSD: args.c,v 1.43 2024/01/26 07:10:04 mlelstv Exp $"); #endif #endif /* not lint */ @@ -248,8 +248,10 @@ f_count(char *arg) { cpy_cnt = strsuftoll("block count", arg, 0, LLONG_MAX); - if (!cpy_cnt) - terminate(0); + if (!cpy_cnt) { + summary(); + exit(0); + } } static void @@ -257,8 +259,10 @@ f_files(char *arg) { files_cnt = (u_int)strsuftoll("file count", arg, 0, UINT_MAX); - if (!files_cnt) - terminate(0); + if (!files_cnt) { + summary(); + exit(0); + } } static void