bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: signal-handling problems for "dd": some thoughts


From: Paul Eggert
Subject: Re: signal-handling problems for "dd": some thoughts
Date: Mon, 19 Apr 2004 11:59:56 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

address@hidden (Paul Jarc) writes:

> Jim Meyering <address@hidden> wrote:
>> I suppose you're referring to this part of the POSIX spec:
>>
>>     The signals SIGUSR1 and SIGUSR2 are commonly used by applications for
>>     notification of exceptional behavior and are described as ``reserved as
>>     application-defined'' so that such use is not prohibited.
>
> This sounds to me like an explicit approval of dd's use of SIGUSR1.

I'm afraid not.  If you look at dd's spec:

http://www.opengroup.org/onlinepubs/007904975/utilities/dd.html

the "ASYNCHRONOUS EVENTS" section specifies the behavior for SIGINT
and says that dd "shall take the standard action for all other signals".
The standard action for SIGUSR1 is abnormal termination; see
<http://www.opengroup.org/onlinepubs/007904975/basedefs/signal.h.html>.

> You mean a program might send SIGUSR1 to other, unrelated programs
> (and therefore not knowing how they handle it)?

Yes.  The basic idea is that SIGUSR1 is reserved for use by the user,
and it's intended to be a fairly fatal signal: if part of a
multiprocess application doesn't know what to do with SIGUSR1, it's
supposed to exit immediately.  "dd" is part of the system, so it can't
appropriate SIGUSR1, and it therefore must exit immediately.

>> The ideal would be to find an approach that avoids adding a new option
>> to each tool that supports a progress bar.
>
> Environment variable?

The way it's done in BSD is that there's a new signal SIGINFO.
Typically the user will do "stty status '^T'"; this will cause a
SIGINFO signal to be sent to all processes attached to the terminal,
when you type control-T.  The default SIGINFO action is to discard
the signal, but BSD "dd" traps it and outputs the progress report.

I suspect what happened is that GNU dd mimicked the BSD behavior, but
when people found out that SIGINFO doesn't exist on other hosts
(including GNU/Linux) they decided to use SIGUSR1 instead.  This isn't
allowed by POSIX.

It gets worse: on the Linux Alpha kernel, SIGINFO is defined, but it's
an alias for SIGPWR (power failure)!  Clearly this is a botch.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]