Forums > MaxMSP

Using [shell] to start a persistent program

November 28, 2010 | 3:00 pm

I need to use Max to start up two unix-based programs upon loadbang. Both of these are audio server type programs, and remain running for as long as you need the audio and OSC to stream, instead of being programs that just execute a few commands and then release you back to the prompt.

So I already need two shell objects, if each one is to "house" one of the two programs for the entire life of the patch. This works fine for this purpose, but ideally, I would like the two programs to "outlive" the patch if something goes wrong and I have to close Max. This is more a safety precaution than anything else.

As I understand it, if I close the patch or delete/reinstantiate a shell object, the running process in it dies. Is this true?

If so, I suppose the best solution would be for me to use [shell] to boot up two Terminal windows (I’m on a Mac) and somehow send them each the instructions to start their respective program. This way, the stability of the programs is in Terminal’s hands rather than the [shell] object within the patch.

Is this possible/reasonable?

November 28, 2010 | 4:32 pm

You could also look into the nohup command, e.g. "nohup ". This will make the command immune to the signal that gets sent when the controlling terminal is closed.

The downside is that you’d then have to kill those processes manually although there are way to make that a little more graceful.

November 29, 2010 | 11:05 pm

You can also just use the launchbrowser message to max:

max launchbrowser file://localhost/path/to/program

in a messagebox. Terminal window does open, but there’s always apple-H.


December 3, 2010 | 5:36 am

Thanks, guys!

I didn’t know about either of these mechanisms and they both work great for my purposes.

Viewing 4 posts - 1 through 4 (of 4 total)