Skip to content

Conversation

dmlloyd
Copy link
Collaborator

@dmlloyd dmlloyd commented Jun 4, 2025

As promised in quarkusio/quarkus#48223, here's the draft Process API.

The tests (so far) pass. I want to add more tests and try replacing some usages in Quarkus itself before I will call this ready to merge, but feel free to review now.

@dmlloyd dmlloyd changed the title [WIP] Process API Introduce process API Jun 9, 2025
@dmlloyd dmlloyd force-pushed the process branch 4 times, most recently from 411b40e to 3b231df Compare June 11, 2025 19:54
*
* @param <O> the output type
*/
public sealed interface ProcessBuilder<O>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is reusing ProcessBuilder name that overlaps with jdk ProcessBuilder a good thing?

asking as I hit that IDE default imported java.lang.ProcessBuilder when pasting code :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I don't know. I thought that any code using this would definitely not be using the JDK one. The fact that the JDK one is in java.lang is a bit annoying though. But I couldn't actually think of any better name... 🤔

/**
* {@return the captured error output of the process execution, if any}
*/
public List<String> errorOutput() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this stderr only ? what about stdout?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could capture stdout here, but doing so would mean adding "tee" support broadly. This can be done, but would require more effort. It's also possible that we could introduce this in the future.

@dmlloyd
Copy link
Collaborator Author

dmlloyd commented Jun 12, 2025

Not implemented, and not sure about relative importance:

  • Background process execution
  • Terminate-process-gracefully on shutdown (this would not work on Windows, so I'm hesitant)
  • Terminate-process-forcefully on shutdown (not sure this is a good idea)
  • I/O thread timeouts (implement via interruption)
  • General output and error tee support
  • Any kind of overall "result" abstraction (if you want to know the success exit code, you have to capture it in your error checker)
  • Virtual thread support (this would be done via MR-JAR, to automatically use a VT thread factory if the calling thread is a VT; we'd also need to check to see if process I/O is VT-friendly)
  • Incremental environment editing (addEnv(), removeEnv() etc.)
  • Debug log of process command name, arguments, output (the concern here is security)

@dmlloyd dmlloyd marked this pull request as ready for review June 16, 2025 13:19
@dmlloyd
Copy link
Collaborator Author

dmlloyd commented Jun 16, 2025

I'm going to provisionally merge this so that I can push up a beta release, which will allow for comprehensive testing and review in Quarkus. We should not release a final version until we have a broad consensus that the API is OK.

@dmlloyd dmlloyd merged commit c864260 into smallrye:main Jun 16, 2025
4 checks passed
@dmlloyd dmlloyd deleted the process branch June 16, 2025 13:23
@github-actions github-actions bot added this to the 3.0.0 milestone Jun 16, 2025
@dmlloyd dmlloyd modified the milestones: 3.0.0, 2.13.beta1 Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants