Hi,

Per this bit from POSIX on dd(1):

> For SIGINT, the dd utility shall interrupt its current processing,
> write status information to standard error, and exit as though
> terminated by SIGINT.  It shall take the standard action for all
> other signals; see [...].

I think we ought to exit nonzero when SIGINT'd.  FreeBSD, NetBSD,
Solaris, AIX, etc., all do, though they all have chosen their own
exit codes.

NetBSD actually goes so far as to restore the original signal handler
for SIGINT and then raises SIGINT again:

http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/dd/misc.c.diff?r1=1.19&r2=1.20&only_with_tag=MAIN&f=h

This is the most unique interpretation I found.  But my gut says that
this is a misreading of "exit as though terminated by SIGINT," and that
exiting with 128 + signo is closer to what was meant.

Thoughts?

--
Scott Cheloha

Index: bin/dd/misc.c
===================================================================
RCS file: /cvs/src/bin/dd/misc.c,v
retrieving revision 1.21
diff -u -p -r1.21 misc.c
--- bin/dd/misc.c       13 Aug 2017 02:06:42 -0000      1.21
+++ bin/dd/misc.c       24 Oct 2017 01:38:10 -0000
@@ -111,9 +111,8 @@ summaryx(int notused)
 }
 
 void
-terminate(int notused)
+terminate(int signo)
 {
-
        summary();
-       _exit(0);
+       _exit(128 + signo);
 }

Reply via email to