Skip to content

Fermeture des file descriptors standard et conformance à POSIX #21

Open
@dariuskramer

Description

@dariuskramer

Les tests qui vérifie la fermeture d'un fd standard avec l'opérateur &-, par exemple 21sh > redirections > inputs > 001-close-stdin, sont marqués comme échoué si le fd est remappé sur /dev/null.

Hors la Rationale, et par extension POSIX, ne recommande pas ce comportement.
Cf http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html, section C.2.7 Redirection:

Applications should not use the [n]<&- or [n]>&- operators to execute a utility or application with file descriptor 0 not open for reading or with file descriptor 1 or 2 not open for writing, as this might cause the executed program (or shell built-in) to misbehave. In order not to pass on these file descriptors to an executed utility or application, applications should not just close them but should reopen them on, for example, /dev/null. Some implementations may reopen them automatically, but applications should not rely on this being done.

Un possible fix serait que si le premier call à read retourne 0, alors on suppose que le fd est mappé sur /dev/null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions