Skip to content

--kill-others-on-fail flag not working as expected with --group --max-processes 1 #433

Closed

Description

@daniil4udo

Description

When trying to run multiple scripts sequentially using concurrently, I noticed that the --kill-others-on-fail flag is not behaving as expected when used together with the --group --max-processes 1 flags, rest of the scripts still running.

Expected Behavior

If one script fails (exits with a non-zero code), all running processes should be terminated when using the --kill-others-on-fail flag, even when running scripts sequentially with --group --max-processes 1.

Current Behavior

However, when I use the --kill-others-on-fail flag in conjunction with --group --max-processes 1, concurrently is not terminating all running processes when one script fails. This behaviour is not observed when I remove --group --max-processes 1 from the command.

Activity

  1. gustavohenke commented on Aug 11, 2023

    @gustavohenke
    Member

    Thanks for the report! I think this use case makes sense.

    There's a potentially funny interaction with --restart-tries here. The first command will restart N times before giving up, but should other commands be given a chance to spawn at all?

  2. bozdoz commented on Dec 7, 2023

    @bozdoz

    How about a --kill-others-on-sigint? I'm not sure I understand the interaction with "restart" here. If the user cancels the process, I'd expect the main process (concurrently) to stop the subprocesses.

    Don't the restart flags default to 0?

  3. gustavohenke commented on Dec 7, 2023

    @gustavohenke
    Member

    Don't the restart flags default to 0?

    Yes.

    The issue I see starts like this:

    concurrently --kill-others-on-fail --max-processes 1 "sleep 5 && echo foo" "exit 1"
    
    • Current behaviour is that command 1 exits, and a SIGTERM (from --kill-others-on-fail) is sent to nowhere, so command 0 still runs
    • New behaviour would be that command 0 shouldn't be given a chance to run, since it was meant to be killed anyways.

    But once you add --restart-tries 1, then it's fair that command 0 gets a chance to run... or not really?

  4. bozdoz commented on Dec 7, 2023

    @bozdoz

    Should restart give the commands a chance to run? No. Not on SIGINT. The user is aborting the process.

    Thinking of docker restart policies:

    • on-failure
    • always
    • unless-stopped

    None of these restart when the container is manually stopped: even "always" explicitly doesn't include if it's manually stopped.

  5. gustavohenke commented on Dec 12, 2023

    @gustavohenke
    Member

    Yeah, SIGINT has a quite clear use case.

    So, --restart-tries is documented as "restart processes that died". If there's a limited concurrency, then not all commands will be running at once, so they should probably not be given a chance to spawn at all when --kill-others/--kill-others-on-fail is set.

    I think this makes sense. WDYT?

  6. gustavohenke commented on Sep 8, 2024

    @gustavohenke
    Member
  7. added theissue type on May 5, 2025
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

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions