Trying to pause and restart a process from Max using aka.shell – format issue?
I am having what must be formatting issues with aka.shell. 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 aka.shell. Instead, I’m trying to query for the PID using, then send the kill message with a flag to aka.shell 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 aka.shell 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  – though incidentally it would be great to find a solution that works for windows too. Thanks so much for any suggestions.
Sorry, my attachment didn’t work in my last post. Trying again…
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!
----------begin_max5_patcher---------- 1534.3oc0Zs0aaaCE94jeEDFnOMWCQRcsusstNTfgVCjf8RSw.sDssVjI0jn Vh6k+6iWjbk8jkjsbLrewLj5FOeemyge7v70auYzL9yz7Qf2.9D3la95s2bi dH0.2T1+lQqHOGlPx021nP9pUTlXzXy0DzmE5wcm.9.+IPHOcMPrjBdXziwI IfWe26+8e8ie3dvml99294GFAVQyyIKnfXlfCH.AMaULij.HrHvxXAP9toYS .2+a2c+OOcJHeIuHIBjQIooTRFfHzucAOEvmq+yj3bAfy.jPQ7+FKVCVwYwB d1jpoXRLiFxKX54oc4foDQ3xX1h+JiFJL1uq0Dqw.aKcCLHP03H6.9b4yDGo sT9r+90Pb0aeNmIXjUT8k9SZVDgQptFqPZaITgF4f+XP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IH3mBUBkt1sWyDuqEUBaNpigAJpyqn ykAcu3.kc1V0OBOxAjhmCAeSkgMsJE5vfnxCaC5211uvviVpvrEg7Ddl4iZM AE3agCjeI0myx7iCzy01ay28PQU8CpWCXmCNWa0pw2FpykKvDVgQUkdF7C6N hlKhY5ERqcSpXmZ2zx3nHJqd9gUwQobY5q7p8wEnpVCNvwrJiuoVE06Awls5 YquScOvmazcouVh5nFN8VhmwRrg0NO9s6Aw1aYI1C1R5GmH2.L.d3bhWfY4C OSyV8LIKrcbM1bvYhSbOPKYGNAtEmX5A0dW195pFp6MPKQUKsNsjcHtNsjSw bB1E5ZeVmSpyqoSbBhNu3Tu7BOv4D1Dt6YqZPNa5bJvut3Tn24kSg8gSOu9Y 6.A6YN4bLbJJPmCoLgot2.mr98ctBOe3WehS8OL3CpW2PUSacCZSug5+Y0iX B+yK741mTJ3yaHQPelSm2kn1AB1iqevYcN0moDFdfYNLZRJ+ugA6hanmQ3ak NQK+gqIoONgvyK1BeADgOTevdsTg64cN0mTZPqiRXLxwu1QD2bOO7l6bKKQ1 4629ec+bvn. -----------end_max5_patcher-----------
Hi again forum,
Sorry to post again but I’m getting desperate!
I tried both shell and aka.shell 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 aka.shell 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.
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
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
* http://www.opensource.apple.com/apsl/ 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
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
* Copyright (c) 1992 NeXT Computer, Inc.
#define _I386_SIGNAL_H_ 1
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.
#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:
----------begin_max5_patcher---------- 1541.3oc2Ys0aaaCE9YmeEGXf9zbMDojrjxaaqqCEXn0.IXuzDLPKQaqEYRM Ipk310+6iWjbcRrkXhu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vzB9hxkKlvyZyZvqtgIlJjZshZr6qfJpk9GkYowzVST1XIXF7Z0f .6bp4jzExfs.YvVfLnnWKgOvCgeQVjopHz+ohVrD5HdhwaBU294.+1PofSll QhFBuWFSQ2hv2mxRnECf+fTwzMfFH44RqGhHU0PWVxlajHLNM9FnjufZZ7nX NQV+dUAqTuntewkbyxxJ6MWTPIvTWWvp6JXSML9R4gAFzz+xYET4QCVqg1Cj 4DyyHRaa0OeKuHYUOqkmvXtdUEJqZL8RdUg5OFHkqKBo6gakn14othSW21tU B+WblEcdjy5NdVa12dwjt+XOy4VBApaGUaQ+bVOaoaPqQ+NUpSPvstJgZ621 6iRvqgFSptpDK.D0kZzYZvQG5FuoRCV6Kbv60edIPptKF9OUT17lvnV.U02L GJrsif4h9gcDr5UmLKlmwKLOsyPbTniajTfURsi4CeTvHuf6E2Q+R04AdvEv qAD052GpKkIYhaDol14CeGRRnkhTlNY55OTv8dn4oIIT15wHVjljykgvJatP gHUOdb8vlaCG83Y0sFE6EsZ1VBnZqln5699WS7MZh4RiZzj6Ma+qI1wIRua. 8L3DTir67nYHckAdg5NzomsiZhpwUqIjaQS7dZbx9Pl5BcefwzgVlry1M7Ix 3M1tQqyw2eluYlzf1ud1NpIgVnHOvp3fCtnCPfgcUlrwFD8zDIWiGd8825Nx cCybBWOVkS3tGqJvFBezQEbw1ftplDbLkIrEQBQAGeYpSbBebkIabVQG2LFp Ns0I2EdTioYkHgbdVkHf8CW6lo17r.2UO4tlNNxlnyG2zwn.ayh8TBOa.2Hj AG+9rcUXGYC.5dbAPajIzwUjrpnZ7ygSQAdFugUS1UY0l.ygOMQEoKwScej5 A7pYO37jm8sy9eDvCNeI -----------end_max5_patcher-----------
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.