Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--success last does not work while --success first does #185

Closed
sergeyevstifeev opened this issue Feb 17, 2019 · 15 comments
Closed

--success last does not work while --success first does #185

sergeyevstifeev opened this issue Feb 17, 2019 · 15 comments

Comments

@sergeyevstifeev
Copy link

sergeyevstifeev commented Feb 17, 2019

Expectation
Switching the order of two commands while simultaneously switching from --success last to --success first should not change the exit status of concurrently

Observed behaviour
--success last does not work as expected when used together with --kill-others

Version
4.1.0

Steps to reproduce
Take two commands: sleep 5; exit 0; and sleep 100, and switch their order. With --success first works correctly:

$> concurrently --kill-others --success first 'sleep 5; exit 0;' 'sleep 100'
[0] sleep 5; exit 0; exited with code 0
--> Sending SIGTERM to other processes..
[1] sleep 100 exited with code SIGTERM
$> echo $?
0

With --success last works incorrectly (expected to get exit code 0 same as above):

$> concurrently --kill-others --success last 'sleep 100' 'sleep 5; exit 0;'
[1] sleep 5; exit 0; exited with code 0
--> Sending SIGTERM to other processes..
[0] sleep 100 exited with code SIGTERM
$> echo $?
1
@jcollum-nike
Copy link

Maybe this is what I'm seeing right now...

@jcollum-nike
Copy link

YEP! Changing the order of commands fixed the issue I was seeing.

4.1.0

@wilgert
Copy link

wilgert commented Apr 16, 2019

We are running into the same problem. Switching the order of commands helps but we are afraid that it introduces unstable behavior.

@jcollum-nike
Copy link

maybe you need a pre script for the thing that definitely needs to happen first?

@RynatSibahatau
Copy link

I have the same issue for both first and last on 4.1.0. Seems there is no issue in 4.0.1.

@jcollum-nike
Copy link

jcollum-nike commented Apr 29, 2019

I think this might be related #187

@gustavohenke
Copy link
Member

Hello all! I'm sorry that I took this long to reply.

I think there's a misconception with how --success works.
From its description:

-s, --success     Return exit code of zero or one based on the success or
                  failure of the "first" child to terminate, the "last child",
                  or succeed only if "all" child processes succeed.
                            [choices: "first", "last", "all"] [default: "all"]

Please pay special attention to the first child to terminate part.
Although @sergeyevstifeev showed that he inverted the order of his commands, they are still exiting in the same order.

@gustavohenke
Copy link
Member

Does the above help anyone? 🙂

@sergeyevstifeev
Copy link
Author

@gustavohenke Ah, I see, this makes sense now. A bit hard to understand from the description, since "first" can be both time-wise and order-wise 🙂

@gustavohenke
Copy link
Member

Maybe first-specified/last-specified (or better names!) could be made options for --success?

@jcollum-nike
Copy link

jcollum-nike commented Jul 8, 2019

I'd like it if I could specify which process is the exit code I care about, --exit=2 or something (3rd process in array is the one I care about)

@gustavohenke
Copy link
Member

That SGTM too -- make --success accept a number, which refers to the process index.

@gustavohenke gustavohenke reopened this Jul 23, 2019
@jcollum-nike
Copy link

I'd be happy with

  • --success=2 means the 3rd item in the array is the one that sets the exit code
  • --success=all: any non-zero exit code will result in a non-zero exit code for the group of processes
  • (not set): exit codes are irrelevant / ignored

@gustavohenke
Copy link
Member

  • (not set): exit codes are irrelevant / ignored

Hmm that's a breaking change. The default is all.

Anyway, I'm happy to review PRs for this 🙂

@paescuj
Copy link
Collaborator

paescuj commented May 20, 2022

Implemented by #318 which has been released in v7.2.0.

@paescuj paescuj closed this as completed May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants