Forums > MaxMSP

Trying to pause and restart a process from Max using – format issue?

Feb 05 2011 | 3:32 am

Hi guys,
I am having what must be formatting issues with I am trying to pause and resume a Max runtime app from another Max runtime app. I don’t want to kill the process entirely and reopen the app, I’ve gotten that to work with the kill command to Instead, I’m trying to query for the PID using, then send the kill message with a flag to when the app is not in use:
kill -SIGSTOP [PID#]
Then I want to restart the process with:
kill -SIGCONT [PID#]
These messages work just fine from the terminal, but just gives me a "no result" error message.
I have attached both a patch and a simple test app to easily reproduce the problem – just unzip the folder and launch the file "pauseprocess.maxpat" (there are instructions in comments) then launch TESTAPP from the finder and turn on the audio.

TESTAPP is just a bunch of copies of the filtergraph help file all connected to an ezdac with the volume turned down. It’s meant to just do some dsp and show up in the activity monitor eating around 9% of cpu – this way you can see the difference when the process is successfully paused.

I’ve been playing around with quotes, the symout argument in sprintf… am I missing a backslash somewhere? I think I’m just doing the flag wrong somehow because the kill command by itself works from max for me. I’m on a MacBook Pro, OSX 10.6.3 running Max 5.1.4 [42462] – though incidentally it would be great to find a solution that works for windows too. Thanks so much for any suggestions.

Feb 05 2011 | 3:37 am

Sorry, my attachment didn’t work in my last post. Trying again…

Feb 05 2011 | 3:50 am

ok it looks like that one didn’t work either. Here, at least, is the patch. Just pick an application that eats some cpu and type it into the message box at the top where it says TESTAPP. thanks!

-- Pasted Max Patch, click to expand. --

Feb 05 2011 | 11:14 pm

Hi again forum,
Sorry to post again but I’m getting desperate!
I tried both shell and with the same result.
kill [PID] from max works just fine with both, but the flag -SIGSTOP is not understood. This works fine in the terminal, but I can’t figure out why it doesn’t work from max! Please help, I’m so close… but I’ve put in so many hours on researching this – I’ve scoured the forums, google, applescript docs, unix commandline docs, the cycling docs, any examples of or shell i could find, direct ;max messages, regexp and sprintf docs, ANY SUGGESTIONS AT ALL VERY WELCOME, at this point they could involve dark magic and I would be fine with that:)
All I want to do is pause and restart a process on the OS level without killing it entirely.

Feb 06 2011 | 2:03 am

it worked for me with shell object when instead of using the signal symbol, i used the signal number.
i had to find the signal.h header file, which lists the numbers.
on snow leopard, stop is 17 and cont is 19:
kill -17 16248

Feb 06 2011 | 3:44 am

Hi Robert! THANKS SO MUCH! I don’t use all caps lightly. I’ve spent the last 3 days/nights trying to figure this one out. That worked great, and if anyone else needs it I’m including the patch at the bottom of this post. Just one other question though, I couldn’t figure out how you got those numbers 17 and 19. I found 3 copies of signal.h on my computer and they didn’t seem to list commands – though maybe I’m not reading it right? I only ask because I’m trying to make this program extremely portable. Since other people will be running different OS versions etc, will this same trick work? or will I have to somehow query their signal.h file from my program? Here is what mine looks like:

* Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the ‘License’). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
* Please obtain a copy of the License at
* and read it before using this file.
* The Original Code and all software distributed under the License are
* distributed on an ‘AS IS’ basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* Please see the License for the specific language governing rights and
* limitations under the License.
* Copyright (c) 1992 NeXT Computer, Inc.

#ifndef _I386_SIGNAL_H_
#define _I386_SIGNAL_H_ 1


#ifndef _ANSI_SOURCE
typedef int sig_atomic_t;

#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)



* Information pushed on stack when a signal is delivered.
* This is used by the kernel to restore state following
* execution of the signal handler. It is also made available
* to the handler to allow it to properly restore state if
* a non-standard exit is performed.
#define __need_struct_sigcontext

#endif /* __APPLE_API_OBSOLETE */
#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
#endif /* ! _ANSI_SOURCE */

#endif /* _I386_SIGNAL_H_ */

Anyway, thanks so much again for your help. it was just what I needed!
And here is the patch that worked:

-- Pasted Max Patch, click to expand. --

Feb 07 2011 | 4:48 pm

yeah, i’m not sure how portable this solution is.
the signal.h file that lists the values is actually from the Developer SDK. you would have to install the xcode developer tools to have access to that.

but since this would only work on mac anyways, maybe the codes stay consistent.

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

Forums > MaxMSP