Skip to content

Is there a way to close after N seconds? #40

Closed

Description

@bahmutov

I am using parallelshell to perform end 2 end testing, like starting a server and then making a request from another script. Most of the time, there is no error, and the request script finishes with exit code 0. Is there an option to kill everything after N second timeout if the processes have not finished before with a non-zero code?

Activity

  1. Yaakov-Belch commented on Sep 6, 2016

    @Yaakov-Belch

    Here is a solution that works with the current parallelshell:

    parallelshell your_programs 'perl -we "sleep 10; exit 2;"'
    

    This adds to your list one process that waits 10 seconds (you can change this number) and then fails. Parallelshell with detect this failure and kill all the other processes.

  2. self-assigned this
    on Oct 18, 2017
  3. darkguy2008 commented on Sep 30, 2026

    @darkguy2008
    Owner

    Hey! Sorry for the long delay 😅 this was just added in 3.1.0! 🎉

    Use parallelshell --timeout 10 "command1" "command2" (or -t) to stop remaining commands after 10 seconds, including with --wait.

    I got it verified across Node 4-26 on Linux x86_64 and Windows. On Unix it uses the existing SIGINT shutdown behavior, so processes that ignore SIGINT or leave descendants running remain a limitation. That depends on the process though, feel free to reopen if it's still an issue.

    Thanks!

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions