File buffer not flushed when terminating LO as a service

Frankly, I don’t know how to ask my question to a search engine and get a reasonable number - or any - relevant matches. If this is a repeat, I apologize…

I am running LO “as a service” (not quite, but close enough) to be able to execute a long-running macro with various parameters in parallel in the background. It is working well (enough), except that should I terminate a task, anything written to the log file that it writes to does not get flushed prior to termination when I use the HANGUP signal.

Is there a way to terminate a LO background process that will flush the buffers - basically the equivalent of pressing the Stop button if I were to run the macro from the Edit Macros window (which does seem to flush the buffer)? Would a different signal work? Something else?

I know I can close and re-open the log file periodically, and I have code to do that in certain places. But my concern is that if I throw that in every time I write to the file (not terribly unreasonable code-wise) that it will prolong an already-long-running process…

I am also aware of the Stream API’s, but don’t really want to re-write all of the logging. (Wish I knew about that at the start!) That doesn’t mean that I won’t…

Any alternative ideas would be appreciated!

Thanks,

Carl

P.S., For what I’m asking it to do, it’s not surprising that the macro takes a long time (in certain cases). I’m looking into possible bugs, but that is semi-unrelated…

P.P.S. In the hope of helping others trying to do similar (as I found no posts relating to running a macro as a job in my searches anywhere), the way that I set up being able to run a macro in parallel like this was the realization that the -env:UserInstallation parameter that I’ve seen referenced in many other posts relating to LO as a service re-creates the LO folders where the macros are stored. I copy my home LO directory to “job” directories, and point the env to each directory for each job. Not only can I run multiple instances of my macro, I can edit what I have (in my home directory) while the jobs are running without any issues. Of course, I have to stop the jobs, copy the macros, and restart, but I can live with that…

Any signal that your macro can recognize will do, for example, the appearance of a specific file in a specific directory.