|
|
Suspend and resume any program using SIGSTOP
Here are zsh functions so one can automate the process in the terminal. Simply stop [processname] and then cont [processname]. (Note: due to the ambiguity of LaunchCFM applications' process names, it's an all-or-nothing proposition: you would have to pause all such Carbon apps with stop CFM, then cont CFM):
##------stop/continue processes------##
stop () {
PID=$(ps auxcww | grep -i "$1" | awk '{print $2}');
mkdir -p /tmp/run;
echo "$PID" > /tmp/run/"$1".pid;
kill -STOP $PID;
}
cont () {
kill -CONT $(cat /tmp/run/"$1".pid);
rm /tmp/run/"$1".pid;
}
2nd method handles Carbon apps
Normally I prefer to limit ps output by using the u and c flags, thus avoiding the need for the second grep process and another pipe. In this case, however, it seems best to add a bit of inefficiency for the sake of functionality. These functions can now handle Cocoa and Carbon apps by (case-insensitive) name. For example, stop entourage and cont entourage now works.
##------stop/continue processes------##
stop () {
PID=$(ps axww | grep -i "$1" | grep -v grep | awk '{print $1}');
mkdir -p /tmp/run;
echo "$PID" > /tmp/run/"$1".pid;
kill -STOP $PID;
}
cont () {
kill -CONT $(cat /tmp/run/"$1".pid);
rm /tmp/run/"$1".pid;
}
2nd method handles Carbon apps
Is it possible to setup an external functions library for sourcing in tcsh shell? I have a few function including the above, that I would like to make available to every shell so I would like it sourced with the inits. Is it even possible in tcsh?
zsh functions ?
where to you put zsh function definitions in order to be able to use them on the command line? it is not the .cshrc, is it?
zsh functions ?
With zsh you can put the functions just about anywhere you like:
Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login shell, commands are read from /etc/zpro- file and then $ZDOTDIR/.zprofile. Then, if the shell is interactive, commands are read from /etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the shell is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read. If ZDOTDIR is unset, HOME is used instead. Those files listed above as being in /etc may be in another directory, depending on the installation.These functions should also work under the bash shell, but I have not tested them in that environment.
Suspend and resume any program using SIGSTOP
Easier.
Suspend and resume any program using SIGSTOP
killall -STOP [procname ...]Sans "SIG" easier. :-) |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.13 seconds |
|