[Plugin development] output flushing for long running Launcher commands

I’m developing a plugin which runs commands for jobs (mostly kubectl) on the Jenkins node via Launcher. At the moment I have such code:

   ByteArrayOutputStream cmdLogStream = new ByteArrayOutputStream();
   int status =  launcher.launch().stdout(cmdLogStream).cmds(args).join();
    if (status != 0) {

This works fine and I get the output printed after the command finishes with non-zero error code.

Now I want to improve the output in Jenkins jobs for long running commands. I have a dozen commands which run 5-10 minutes and they output their work to stdout during that time constantly. The problem is Launcher.join() always waits until the command finishes and only then outputs everything in one go.
I cannot wrap my head on where and how to flush stdout as soon as the content is changed so my Jenkins jobs will return that content immediately and inform the end user what’s going on in the job process. Are there any examples of this somewhere? Is this even possible with Launcher?

Ping. Can anyone guide me with this?

The Launcher you get for a build will stream its output to the build log by default. You should not need to do anything. Perhaps you constructed your Launcher manually rather than accepting the one provided by the relevant interface?