How to be sure ShutDown actions run?

(
Library.put(\jackmidipid, "a2jmidid -e -u".unixCmd);
ShutDown.add { "kill -9 %".format(Library.at(\jackmidipid)).systemCmd };
)

It turns out this case isn’t critical (because a2jmidid doesn’t open multiple instances, and stopping JACK kills off a2jmidid too).

But it’s untidy. Language shutdown doesn’t wait for shutdown actions to complete… not sure what to do about that.

(Other untidiness: Quit SC while a2jmidid is still open, and SC hangs until you quit the JACK server – which wouldn’t happen if it completed the ShutDown action.)

hjh

Further investigation: I think I may have been bitten by the fact that aString.unixCmd returns the PID of the shell running the command, not the command itself. It probably was killing the shell, but for some reason I don’t know, not killing the child process.

This morning I tried with ["a2jmidid", "-e", "-u"].unixCmd and then quitting SC was fine (and did take down the a2j JACK MIDI ports).

(But I remember a bug report about writing a file at shutdown, where the file wasn’t saved correctly because sclang terminated before that was finished.)

hjh