Skip to content

run/runAsync without blocking jvm shutdown #585

Description

@maxandersen

currently ProcessBuilder blocks jvm shutdown if processes have not finished at jvm shutdown:

///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 21+
//DEPS io.smallrye.common:smallrye-common-process:2.20.0

import static io.smallrye.common.process.ProcessBuilder.*;
public class SmallRyeProcessShutdown {
    public static void main(String[] args) {
        var seconds = args.length == 0 ? 3 : Integer.parseInt(args[0]);
        newBuilder("sleep", Integer.toString(seconds))
                .whileRunning(process -> System.out.println("child pid: " + process.pid()))
                .runAsync();

        System.out.println("main() returning immediately; child sleeps for " + seconds + "s");
    }
}

any reason why?

forces me to use other API's to kick off background jobs.

Thats sad :)

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