OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 2 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE.md file. | 4 # BSD-style license that can be found in the LICENSE.md file. |
5 | 5 |
6 # This program displays information about the Fletch persistent process. | 6 # This program displays information about the Dartino persistent process. |
7 # | 7 # |
8 # It supports an option -k (or --kill) which will kill the process after | 8 # It supports an option -k (or --kill) which will kill the process after |
9 # displaying the information. | 9 # displaying the information. |
10 # | 10 # |
11 # This is a tool that's intended for people building the Fletch VM. If you find | 11 # This is a tool that's intended for people building the Dartino VM. If you find |
12 # yourself using this on a regular basis, please get in touch with the authors | 12 # yourself using this on a regular basis, please get in touch with the authors |
13 # and let us know why. If you're unsure about how to reach the authors, you're | 13 # and let us know why. If you're unsure about how to reach the authors, you're |
14 # welcome to file an issue at https://github.com/dart-lang/fletch/issues/new. | 14 # welcome to file an issue at https://github.com/dart-lang/dartino/issues/new. |
15 | 15 |
16 # Using ~ instead of $HOME as this should match what the fletch command does | 16 # Using ~ instead of $HOME as this should match what the dartino command does |
17 # (it will fall back to getpwuid_r if HOME isn't defined). | 17 # (it will fall back to getpwuid_r if HOME isn't defined). |
18 fletch_file=~/.fletch | 18 dartino_file=~/.dartino |
19 | 19 |
20 if [ -f "$FLETCH_SOCKET_FILE" ]; then | 20 if [ -f "$DARTINO_SOCKET_FILE" ]; then |
21 fletch_file="$FLETCH_SOCKET_FILE" | 21 dartino_file="$DARTINO_SOCKET_FILE" |
22 fi | 22 fi |
23 | 23 |
24 for argument in "$@"; do | 24 for argument in "$@"; do |
25 case "$argument" in | 25 case "$argument" in |
26 -k|--kill) | 26 -k|--kill) |
27 kill=1 | 27 kill=1 |
28 ;; | 28 ;; |
29 -*) | 29 -*) |
30 echo Unknown option: "$argument" >&2 | 30 echo Unknown option: "$argument" >&2 |
31 has_bad_options=1 | 31 has_bad_options=1 |
32 ;; | 32 ;; |
33 *) | 33 *) |
34 fletch_file="$argument" | 34 dartino_file="$argument" |
35 ;; | 35 ;; |
36 esac | 36 esac |
37 done | 37 done |
38 | 38 |
39 if [ $has_bad_options ]; then | 39 if [ $has_bad_options ]; then |
40 exit 1 | 40 exit 1 |
41 fi | 41 fi |
42 | 42 |
43 for socket in $(xargs < $fletch_file) ; do | 43 for socket in $(xargs < $dartino_file) ; do |
44 if [ -e "$socket" ] ; then | 44 if [ -e "$socket" ] ; then |
45 for pid in $(lsof -t -- "$socket" ) ; do | 45 for pid in $(lsof -t -- "$socket" ) ; do |
46 echo Persistent Fletch process $pid: | 46 echo Persistent Dartino process $pid: |
47 ps -w -w -o args= -p $pid | 47 ps -w -w -o args= -p $pid |
48 if [ $kill ]; then | 48 if [ $kill ]; then |
49 kill -TERM $pid | 49 kill -TERM $pid |
50 : > $fletch_file | 50 : > $dartino_file |
51 fi | 51 fi |
52 done | 52 done |
53 fi | 53 fi |
54 done | 54 done |
OLD | NEW |