View Issue Details

IDProjectCategoryView StatusLast Update
00007601003.1(2013)/Issue7+TC1Shell and Utilitiespublic2019-06-10 08:55
Reportergeoffclare Assigned To 
PrioritynormalSeverityObjectionTypeError
Status ClosedResolutionAccepted 
NameGeoff Clare
OrganizationThe Open Group
User Reference
Section2.9.3.1
Page Number2342
Line Number74502
Interp StatusApproved
Final Accepted TextSee 0000760:0001929
Summary0000760: asynchronous list assignment of stdin should depend on job control
DescriptionXCU 2.9.3.1 Asynchronous Lists states:

    The standard input for an asynchronous list, before any explicit
    redirections are performed, shall be considered to be assigned to
    a file that has the same properties as /dev/null. If it is an
    interactive shell, this need not happen.

What matters here is not whether the shell is interactive or not, but
whether job control is enabled or not.

Also, I'm not sure why this behaviour is allowed when job control
is enabled. It means that users cannot rely on being able to start
an interactive program in the background and then use "fg" to bring
it to the foreground when they need to provide it with some input
(having been notified that it was stopped with SIGTTIN). The desired
action disallows the behaviour when job control is enabled, as I
believe this change would be non-controversial. However, if this
change is not felt to be appropriate for TC2, it could be deferred
until Issue 8 (in which case the change in TC2 should say "may"
instead of "shall not").
Desired ActionChange:

    The standard input for an asynchronous list, before any explicit
    redirections are performed, shall be considered to be assigned to
    a file that has the same properties as /dev/null. If it is an
    interactive shell, this need not happen.

to:

    If job control is disabled (see set -m), the standard input for an
    asynchronous list, before any explicit redirections are performed,
    shall be considered to be assigned to a file that has the same
    properties as /dev/null. This shall not happen if job control is
    enabled.
Tagstc2-2008

Relationships

related to 0001254 Closed 1003.1(2016/18)/Issue7+TC2 "asynchronous list" description uses "command" instead of "AND-OR list" 

Activities

nick

2013-10-17 15:50

manager   bugnote:0001929

Interpretation response
------------------------
The standard states that interactive shells need not reassign standard input, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor.

Rationale:
-------------
This does not match existing practice.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
Make the changes suggested in the Desired Action.

ajosey

2014-02-21 15:39

manager   bugnote:0002154

Interpretation Proposed 21 Feb 2014

ajosey

2014-03-25 13:41

manager   bugnote:0002197

Interpretation Approved: 25 March 2014

stephane

2019-06-08 06:11

reporter   bugnote:0004410

Even for non-interactive shells, redirecting stdin to /dev/null when asynchronous is not particularly useful, and has to be worked around probably at least as often as it is useful.

Some shells don't do it. zsh never does it, bash does not do it when that asynchronous list is one single pipeline.

It may be more useful to leave it unspecified then (that might have been the original intention behind the original text: don't do it when interactive, unspecified when not).

It may help to add an informative section that shows how to work around it:

"{ cmd <&3 3<&- & } 3<&0" instead of "cmd &"

BTW, that whole 2.9.3.1 section is incorrect as it refers to "commands" instead of "AND-OR lists". The whole part about the PID doesn't make sense in the context of an "AND-OR list" with more than one part. I'll raise a separate issue about that.

stephane

2019-06-08 06:24

reporter   bugnote:0004411

Last edited: 2019-06-08 06:28

According to 2.9.3.1's "In all cases, explicit redirection of standard input shall override this activity"

cmd <&0 &

should be another work around. While that works in bash, yash (and of course zsh), it doesn't in bosh, dash, ksh93, pdksh, ksh88 (even /usr/xpg4/bin/sh on Solaris).

The wording should be updated to say something like: wherever that happens, it shall happen before the explicit redirection of the command are processed. An implementation may choose not to do it at all if the stdin of the command is redirected.

geoffclare

2019-06-10 08:46

manager   bugnote:0004413

The changes arising from this bug were applied in POSIX.1-2008 TC2, so this is not the right place to request further changes. (All of the bugs tagged tc2-2008 should have been closed some time ago to prevent this situation arising.)

Re: 0000760:0004411 <&0 is a no-op, so it's unclear whether it counts as "explicit redirection of standard input".

Issue History

Date Modified Username Field Change
2013-10-07 09:56 geoffclare New Issue
2013-10-07 09:56 geoffclare Name => Geoff Clare
2013-10-07 09:56 geoffclare Organization => The Open Group
2013-10-07 09:56 geoffclare Section => 2.9.3.1
2013-10-07 09:56 geoffclare Page Number => 2342
2013-10-07 09:56 geoffclare Line Number => 74502
2013-10-07 09:56 geoffclare Interp Status => ---
2013-10-17 15:50 nick Interp Status --- => Pending
2013-10-17 15:50 nick Note Added: 0001929
2013-10-17 15:50 nick Status New => Interpretation Required
2013-10-17 15:50 nick Resolution Open => Accepted
2013-10-17 15:50 nick Final Accepted Text => See 0000760:0001929
2013-10-17 15:59 nick Tag Attached: tc2-2008
2014-02-21 15:39 ajosey Interp Status Pending => Proposed
2014-02-21 15:39 ajosey Note Added: 0002154
2014-03-25 13:41 ajosey Interp Status Proposed => Approved
2014-03-25 13:41 ajosey Note Added: 0002197
2019-06-08 06:11 stephane Note Added: 0004410
2019-06-08 06:24 stephane Note Added: 0004411
2019-06-08 06:28 stephane Note Edited: 0004411
2019-06-10 08:46 geoffclare Note Added: 0004413
2019-06-10 08:55 agadmin Status Interpretation Required => Closed
2019-07-15 15:38 Don Cragun Relationship added related to 0001254