michael@0: #!/bin/sh michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # michael@0: # Find Mozilla PID and send it a signal, to be used michael@0: # with the jprof tool. michael@0: # michael@0: michael@0: jpsignal_usage() { michael@0: echo "Usage: jprofsig [start|stop]" michael@0: exit 1 michael@0: } michael@0: michael@0: if [ $# != 1 ]; then michael@0: echo "Wrong number of arguments." michael@0: jpsignal_usage michael@0: fi michael@0: michael@0: jpsignal_arg="$1" michael@0: michael@0: # Find & print mozilla PID michael@0: tmpmoz=`ps aux | grep mozilla-bin | head -1 | awk '{ print $2 }'` michael@0: echo "Mozilla PID = $tmpmoz" michael@0: michael@0: # See how we were called. michael@0: case "$jpsignal_arg" in michael@0: start) michael@0: if [ "$JP_REALTIME" = 1 ]; then michael@0: kill -ALRM $tmpmoz michael@0: else michael@0: # Normal, non-realtime mode. michael@0: kill -PROF $tmpmoz michael@0: fi michael@0: ;; michael@0: stop) michael@0: kill -USR1 $tmpmoz michael@0: ;; michael@0: *) michael@0: jpsignal_usage michael@0: exit 1 michael@0: esac michael@0: michael@0: exit 0