Hi,

Scott Cheloha wrote on Mon, Oct 23, 2017 at 09:01:04PM -0500:

> 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.

I think that is the correct interpretation, because

  http://pubs.opengroup.org/onlinepubs/9699919799/utilities/dd.html

does not describe SIGINT in more detail,

  http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html

clearly says that SIGINT causes *abnormal* termination by default, and

  
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03

says

  If the default action is to terminate the process abnormally, the
  process is terminated as if by a call to _exit(), except that the
  status made available to wait(), waitid(), and waitpid() indicates
  abnormal termination by the signal.

So when calling _exit() explicitly, we have to pass a status
of 128 + signo indeed.


Of course, this can cause a change of behaviour in scripts, but
it seems more likely to me to fix bugs than introduce any.
A script that relied on dd(1) to succeed on SIGINT would seem
quite badly broken to me.

OK to commit?
  Ingo


> 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