Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Suspend and resume any program using SIGSTOP' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Suspend and resume any program using SIGSTOP
Authored by: gatorparrots on Sep 19, '03 12:01:57AM
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;
}


[ Reply to This | # ]
2nd method handles Carbon apps
Authored by: gatorparrots on Sep 19, '03 12:23:48AM
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;
}
     

[ Reply to This | # ]
2nd method handles Carbon apps
Authored by: bluehz on Sep 19, '03 07:04:26PM

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?

And yes - I know - I should switch to Bash or zsh, BUT since I still consider myself a novice shell scripter and damn near every example (from which I learn) is in sh - I think I will stick with tcsh for a while longer.... hence my request.



[ Reply to This | # ]
zsh functions ?
Authored by: mug1 on Sep 19, '03 04:34:06AM

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?
(might be obvious to most of you... for some maybe it isn't)


---
----
chris



[ Reply to This | # ]
zsh functions ?
Authored by: gatorparrots on Sep 19, '03 01:40:15PM
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.

[ Reply to This | # ]
Suspend and resume any program using SIGSTOP
Authored by: calroth on Sep 19, '03 09:28:40PM

killall -SIGSTOP [processname]

killall -SIGCONT [processname]

Easier.



[ Reply to This | # ]
Suspend and resume any program using SIGSTOP
Authored by: sjk on Sep 20, '03 12:45:22AM
killall -STOP [procname ...]
killall -CONT [procname ...]


Sans "SIG" easier. :-)

[ Reply to This | # ]