Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000347 [1003.1(2008)/Issue 7] Shell and Utilities Objection Error 2010-11-05 12:33 2013-04-16 13:06
Reporter geoffclare View Status public  
Assigned To ajosey
Priority normal Resolution Accepted  
Status Closed  
Name Geoff Clare
Organization The Open Group
User Reference
Section sh
Page Number 3167
Line Number 105344
Interp Status Approved
Final Accepted Text Note: 0000616
Summary 0000347: ASYNCHRONOUS EVENTS on sh page should not be "Default"
Description The ASYNCHRONOUS EVENTS section for the sh utility just states "Default".

There are several problems with this:

    1. It does not take into account the effects of the trap built-in
    utility (including the special requirements in section 2.11
    concerning traps).

    2. It conflicts with the requirements for interrupt handling during
    command line editing in interactive shells, as specified in the
    EXTENDED DESCRIPTION.

    3. It omits other details relating to interactive shells. These
    are described in the sh man page on Solaris 10 as follows:

    If the -i flag is present or if the shell
    input and output are attached to a terminal,
    this shell is interactive. In this case,
    TERMINATE is ignored (so that kill 0 does
    not kill an interactive shell) and INTERRUPT
    is caught and ignored (so that wait is
    interruptible). In all cases, QUIT is
    ignored by the shell.

    The bash man page is similar, but adds:

        If job control is in effect, bash ignores SIGTTIN, SIGTTOU,
        and SIGTSTP.

    Some experimentation with ksh shows that it also ignores these
    job control signals. (Both shells seem to ignore them regardless
    of whether the -m option is set, so I'm not sure what the
    condition "If job control is in effect" in the bash man page is
    referring to; perhaps it is whether the shell was compiled with
    support for job control.)

Additionally, where the EXTENDED DESCRIPTION refers to the interrupt
character being typed, it should specify the same behaviour on receipt
of SIGINT signals generated by other means. The current wording
implies that the shell should distinguish between SIGINT signals that
are generated by typing the interrupt character and by other means,
but in practice shells just handle all SIGINT signals the same way.
Desired Action Change the ASYNCHRONOUS EVENTS section from

    Default.

to

    The sh utility shall take the standard action for all signals (see
    [xref to Utility Description Defaults]) with the following exceptions:

    If the shell is interactive, SIGINT signals received during command
    line editing shall be handled as described in the EXTENDED DESCRIPTION,
    and SIGINT signals received at other times shall be caught but no
    action performed.

    If the shell is interactive, SIGQUIT, SIGTERM, SIGTTIN, SIGTTOU,
    and SIGTSTP signals shall be ignored.

    The standard actions, and the actions described above for
    interactive shells, can be overridden by use of the trap special
    built-in utility (see [xref to trap] and [xref to 2.11]).


At page 3168 line 105387 change

    Typing the interrupt character in command mode shall cause sh to ...

to

    If sh receives a SIGINT signal in command mode (whether generated
    by typing the interrupt character or by other means), it shall ...

At line 105406 change

    Terminate command line editing ...

to

    If sh receives a SIGINT signal in insert mode (whether generated
    by typing the interrupt character or by other means), it shall
    terminate command line editing ...

At page 3178 line 105872 add a new paragraph to RATIONALE

    In interactive shells, SIGTERM is ignored so that kill 0 does not
    kill the shell, and SIGINT is caught so that wait is interruptible.
Tags tc1-2008
Attached Files

- Relationships

-  Notes
(0000616)
msbrown (manager)
2010-11-18 16:30
edited on: 2011-01-27 17:32

Interpretation response
------------------------
The standard states that the "default" behavior is required here, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor.

Rationale:
-------------
See the "Description" section above.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------

Change the ASYNCHRONOUS EVENTS section from

    Default.

to

    The sh utility shall take the standard action for all signals (see
    [xref to Utility Description Defaults]) with the following exceptions:

    If the shell is interactive, SIGINT signals received during command
    line editing shall be handled as described in the EXTENDED DESCRIPTION,
    and SIGINT signals received at other times shall be caught but no
    action performed.

    If the shell is interactive:

    * SIGQUIT and SIGTERM signals shall be ignored.

    * If the -m option is in effect, SIGTTIN, SIGTTOU, and SIGTSTP
      signals shall be ignored.

    * If the -m option is not in effect, it is unspecified whether
      SIGTTIN, SIGTTOU, and SIGTSTP signals are ignored, set to the
      default action, or caught. If they are caught the shell shall,
      in the signal-catching function, set the signal to the default
      action and raise the signal (after taking any appropriate steps
      such as restoring terminal settings).

    The standard actions, and the actions described above for
    interactive shells, can be overridden by use of the trap special
    built-in utility (see [xref to trap] and [xref to 2.11]).


At page 3168 line 105387 change

    Typing the interrupt character in command mode shall cause sh to ...

to

    If sh receives a SIGINT signal in command mode (whether generated
    by typing the interrupt character or by other means), it shall ...

At line 105406 change

    Terminate command line editing ...

to

    If sh receives a SIGINT signal in insert mode (whether generated
    by typing the interrupt character or by other means), it shall
    terminate command line editing ...

At page 3178 line 105872 add a new paragraph to RATIONALE

    In interactive shells, SIGTERM is ignored so that kill 0 does not
    kill the shell, and SIGINT is caught so that wait is interruptible.
    If the shell does not ignore SIGTTIN, SIGTTOU, and SIGTSTP signals
    when it is interactive and the -m option is not in effect, these
    signals suspend the shell if it is not a session leader. If it is
    a session leader, the signals are discarded if they would stop the
    process, as required by [xref to XSH 2.4.3] for orphaned process
    groups.

(0000636)
ajosey (manager)
2010-12-16 16:13

Comments are due on this interpretation by January 16 2011
(0000642)
jilles (reporter)
2010-12-29 14:40

Interactive shells with job control disabled (like set +m) do not really need to ignore SIGTTIN, SIGTTOU and SIGTSTP signals. Not ignoring these signals allows suspending a shell without job control via ctrl+z or similar and allows a better implementation of the non-standard suspend utility than ksh93's
  kill -s STOP $$
as follows
  case $- in *m*) set +m; kill -s TSTP 0; set -m;; *) kill -s TSTP 0;; esac
which properly suspends any other processes in the process group (otherwise, an outer job control shell may wait in vain for the other processes to stop or terminate).

Some ash derivatives such as dash and FreeBSD's sh do not ignore these signals. They also honor +m on the initial command line, unlike bash and ksh93 which enable job control anyway (which is not a disaster, but not what the user asked for).

Interactive shells with job control enabled must ignore SIGTTIN, SIGTTOU and SIGTSTP; otherwise, things like tcsetpgrp() may fail. dash and FreeBSD's sh do this.
(0000661)
ajosey (manager)
2011-01-27 17:40

The notes to the editor in Note: 0000616 have been updated to address the
comments made in Note: 0000642. Comments on this revised interpretation are
due by Feb 27th.
(0000687)
ajosey (manager)
2011-03-04 12:26

This is now an approved interpretation

- Issue History
Date Modified Username Field Change
2010-11-05 12:33 geoffclare New Issue
2010-11-05 12:33 geoffclare Status New => Under Review
2010-11-05 12:33 geoffclare Assigned To => ajosey
2010-11-05 12:33 geoffclare Name => Geoff Clare
2010-11-05 12:33 geoffclare Organization => The Open Group
2010-11-05 12:33 geoffclare Section => sh
2010-11-05 12:33 geoffclare Page Number => 3167
2010-11-05 12:33 geoffclare Line Number => 105344
2010-11-05 12:33 geoffclare Interp Status => ---
2010-11-18 16:27 msbrown Tag Attached: tc1-2008
2010-11-18 16:30 msbrown Interp Status --- => Pending
2010-11-18 16:30 msbrown Note Added: 0000616
2010-11-18 16:30 msbrown Status Under Review => Interpretation Required
2010-11-18 16:30 msbrown Resolution Open => Accepted
2010-11-18 16:30 msbrown Description Updated
2010-11-18 16:30 msbrown Desired Action Updated
2010-11-18 16:31 msbrown Final Accepted Text => Note: 0000616
2010-12-16 16:13 ajosey Interp Status Pending => Proposed
2010-12-16 16:13 ajosey Note Added: 0000636
2010-12-29 14:40 jilles Note Added: 0000642
2011-01-27 17:32 geoffclare Note Edited: 0000616
2011-01-27 17:40 ajosey Note Added: 0000661
2011-03-04 12:26 ajosey Interp Status Proposed => Approved
2011-03-04 12:26 ajosey Note Added: 0000687
2013-04-16 13:06 ajosey Status Interpretation Required => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker