Skip to content

env: --default-signal, --ignore-signal and --block-signal are applied in a fixed order, not in the order given #15187

Closed

Description

@NdekoCode

GNU env applies the signal options in the order they are given, so the last one for a signal wins:

$ env --ignore-signal=INT --default-signal=INT --list-signal-handling true
$ env --default-signal=INT --ignore-signal=INT --list-signal-handling true
INT        ( 2): IGNORE
$ env --block-signal=INT --default-signal=INT --list-signal-handling true
$ env --ignore-signal=INT --default-signal --list-signal-handling true

uutils applies --default-signal first, then --ignore-signal, then --block-signal, whatever their order on the command line, so the first and the last two commands leave INT ignored or blocked (INT (2): IGNORE, INT (2): BLOCK, INT (2): IGNORE). GNU 9.12 and uutils main at a5bc606; the listing itself is #15185.

Activity

  1. AnandajithS commented on Oct 8, 2026

    @AnandajithS
    Contributor

    Hi, I've looked into this . The issue is that we are storing each flag separately and then constructing independent SignalRequests instances for each of them. Then, here we use apply_signal_action to apply them in a fixed order (default, ignore, block)

    To fix this, I was thinking of using a single ordered sequence of SignalOperations. Then during argument parsing, clap::ArgMatches::indices_of() can be used to retain each option's command-line occurrence index. The operations can then be sorted by that index and applied sequentially in run_env. If this is acceptable, I could go ahead and submit a PR

  2. NdekoCode commented on Oct 9, 2026

    @NdekoCode
    ContributorAuthor

    Looks right to me. #13006 rewrites a good part of the signal handling in env.rs and test_env.rs, worth checking it does not collide before you start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions