From crees@zeus.bayofrum.net  Fri Feb 25 16:11:59 2011
Return-Path: <crees@zeus.bayofrum.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id AA89E1065670
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 25 Feb 2011 16:11:58 +0000 (UTC)
	(envelope-from crees@zeus.bayofrum.net)
Received: from relay.pcl-ipout02.plus.net (relay.pcl-ipout02.plus.net [212.159.7.100])
	by mx1.freebsd.org (Postfix) with ESMTP id 4070B8FC08
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 25 Feb 2011 16:11:57 +0000 (UTC)
Received: from outmx04.plus.net ([212.159.14.19])
  by relay.pcl-ipout02.plus.net with ESMTP; 25 Feb 2011 15:43:05 +0000
Received: from [91.125.147.237] (helo=zeus.bayofrum.net)
	 by outmx04.plus.net with esmtp (Exim) id 1Pszou-0000cG-QX
	for FreeBSD-gnats-submit@freebsd.org; Fri, 25 Feb 2011 15:43:05 +0000
Received: from zeus.bayofrum.net (crees@localhost [127.0.0.1])
	by zeus.bayofrum.net (8.14.4/8.14.4) with ESMTP id p1PFed33009779
	(version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 25 Feb 2011 15:40:39 GMT
	(envelope-from crees@zeus.bayofrum.net)
Received: (from crees@localhost)
	by zeus.bayofrum.net (8.14.4/8.14.4/Submit) id p1PFedix009778;
	Fri, 25 Feb 2011 15:40:39 GMT
	(envelope-from crees)
Message-Id: <201102251540.p1PFedix009778@zeus.bayofrum.net>
Date: Fri, 25 Feb 2011 15:40:39 GMT
From: Chris Rees <utisoft@gmail.com>
Reply-To: Chris Rees <utisoft@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] dd(1) dies on SIGUSR1; should print info
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         155034
>Category:       bin
>Synopsis:       [PATCH] dd(1) dies on SIGUSR1; should print info
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 25 16:20:05 UTC 2011
>Closed-Date:    Mon Jun 06 18:20:51 UTC 2011
>Last-Modified:  Mon Jun  6 18:50:05 UTC 2011
>Originator:     Chris Rees
>Release:        FreeBSD 8.1-RELEASE-p2 i386
>Organization:
>Environment:
System: FreeBSD zeus.bayofrum.net 8.1-RELEASE-p2 FreeBSD 8.1-RELEASE-p2 #0: Wed Feb 23 16:10:57 UTC 2011 root@zeus.bayofrum.net:/usr/obj/usr/src/sys/ZEUS i386


>Description:
	[1] describes how SIGUSR1 can be used instead of SIGINFO to get the current status of dd in GNU coreutils, and when I unsuspectingly used SIGUSR1 to query FreeBSD dd just now I killed it...

	I understand that there are differences between systems, but I think that I received a rather harsh punishment here!

	[1] http://www.gnu.org/software/coreutils/manual/coreutils.html#dd-invocation
>How-To-Repeat:
[crees@zeus]~% dd if=/dev/random of=/dev/null &
[1] 9693
[crees@zeus]~% kill -USR1 9693
[crees@zeus]~%
[1]    User signal 1                 dd if=/dev/random of=/dev/null
[crees@zeus]~% fg
fg: No current job.
[crees@zeus]~% j
[crees@zeus]~%
>Fix:

--- dd-sigusr1.patch begins here ---
Index: dd.c
===================================================================
RCS file: /exports/cvsroot-freebsd/src/bin/dd/dd.c,v
retrieving revision 1.43
diff -u -r1.43 dd.c
--- dd.c	15 Aug 2004 19:10:05 -0000	1.43
+++ dd.c	25 Feb 2011 15:31:58 -0000
@@ -90,6 +90,7 @@
 	setup();
 
 	(void)signal(SIGINFO, summaryx);
+	(void)signal(SIGUSR1, summaryx);
 	(void)signal(SIGINT, terminate);
 
 	atexit(summary);
--- dd-sigusr1.patch ends here ---




>Release-Note:
>Audit-Trail:

From: Chris Rees <utisoft@gmail.com>
To: bug-followup@freebsd.org, gavin@freebsd.org
Cc:  
Subject: Re: bin/155034: [PATCH] dd(1) dies on SIGUSR1; should print info
Date: Wed, 2 Mar 2011 19:59:05 +0000

 After IRC feedback, I've amended the patch [1] to ignore the signal,
 rather than print info or die.
 
 Chris
 
 [1] http://www.bayofrum.net/~crees/patches/dd-sigusr1.patch

From: Oliver Fromme <olli@lurza.secnetix.de>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/155034: [PATCH] dd(1) dies on SIGUSR1; should print info
Date: Tue, 22 Mar 2011 16:01:51 +0100 (CET)

 Chris Rees <utisoft@gmail.com> wrote:
  > Maxim Konovalov <maxim.konovalov@gmail.com> wrote:
  > > FreeBSD uses SIGINFO for such purposes for ages in many programs
  > > apart from dd(1). IMHO, nothing to fix here.
  >
  > Of course, and I'm not suggesting that FreeBSD is wrong in any way.
  >
  > My point was that it was rather a harsh punishment for using a GNU-ism
  > where dd died after 30 minutes of chugging or so.
 
 Well, when it died, it did exactly what you told it to:
 Terminating the process is the default action for SIGUSR1,
 see signal(3), and the dd(1) manpage doesn't mention that
 SIGUSR1 is used for anything (in rather states that SIGINFO
 is used for the purpose that you intended), so the default
 action applies.
 
 I tend to agree with Maxim here.
 
  > Would it hurt for dd to ignore the signal rather than die? I imagine a
  > lot less than otherwise.
 
 But then -- for consistency -- you would have to apply the
 same patch to *all* programs that use SIGINFO, such as dump
 and tar.  And what should be done if a program uses SIGINFO
 for status display *and* SIGUSR1 for something completely
 unrelated, such as ftp(1)?
 
 Best regards
    Oliver
 
 -- 
 Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
 Handelsregister: Registergericht Muenchen, HRA 74606,  Geschftsfuehrung:
 secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mn-
 chen, HRB 125758,  Geschftsfhrer: Maik Bachmann, Olaf Erb, Ralf Gebhart
 FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd
 
 "That's what I love about GUIs: They make simple tasks easier,
 and complex tasks impossible."
         -- John William Chambless
State-Changed-From-To: open->closed 
State-Changed-By: jh 
State-Changed-When: Mon Jun 6 18:04:17 UTC 2011 
State-Changed-Why:  
Not a bug. As far as I can see ignoring the signal would violate POSIX: 

"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; - -" 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155034 

From: Chris Rees <utisoft@gmail.com>
To: jh@freebsd.org, bug-followup@freebsd.org
Cc:  
Subject: Re: bin/155034: [PATCH] dd(1) dies on SIGUSR1; should print info
Date: Mon, 6 Jun 2011 19:42:49 +0100

 n 6 June 2011 19:20,  <jh@freebsd.org> wrote:
 > Synopsis: [PATCH] dd(1) dies on SIGUSR1; should print info
 >
 > State-Changed-From-To: open->closed
 > State-Changed-By: jh
 > State-Changed-When: Mon Jun 6 18:04:17 UTC 2011
 > State-Changed-Why:
 > Not a bug. As far as I can see ignoring the signal would violate POSIX:
 >
 > "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; - -"
 >
 
 Clear and unambiguous wording, thank you very much for sorting this!
 
 Chris
>Unformatted:
