|
1 #!/bin/sh |
|
2 # |
|
3 # This Source Code Form is subject to the terms of the Mozilla Public |
|
4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
6 |
|
7 # |
|
8 # Find Mozilla PID and send it a signal, to be used |
|
9 # with the jprof tool. |
|
10 # |
|
11 |
|
12 jpsignal_usage() { |
|
13 echo "Usage: jprofsig [start|stop]" |
|
14 exit 1 |
|
15 } |
|
16 |
|
17 if [ $# != 1 ]; then |
|
18 echo "Wrong number of arguments." |
|
19 jpsignal_usage |
|
20 fi |
|
21 |
|
22 jpsignal_arg="$1" |
|
23 |
|
24 # Find & print mozilla PID |
|
25 tmpmoz=`ps aux | grep mozilla-bin | head -1 | awk '{ print $2 }'` |
|
26 echo "Mozilla PID = $tmpmoz" |
|
27 |
|
28 # See how we were called. |
|
29 case "$jpsignal_arg" in |
|
30 start) |
|
31 if [ "$JP_REALTIME" = 1 ]; then |
|
32 kill -ALRM $tmpmoz |
|
33 else |
|
34 # Normal, non-realtime mode. |
|
35 kill -PROF $tmpmoz |
|
36 fi |
|
37 ;; |
|
38 stop) |
|
39 kill -USR1 $tmpmoz |
|
40 ;; |
|
41 *) |
|
42 jpsignal_usage |
|
43 exit 1 |
|
44 esac |
|
45 |
|
46 exit 0 |