Last change
on this file was
14492,
checked in by westram, 9 years ago
|
- arb_clean
- renamed action 'targets' → 'show_all'
- added new action 'show_session'
- both 'show_…'-actions use 'ps' to create process listing (instead of just dumping PIDs)
|
-
Property svn:eol-style set to
native
-
Property svn:executable set to
*
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
2.1 KB
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | |
---|
3 | remove() { |
---|
4 | local PIDFILE=$1 |
---|
5 | rm -f $PIDFILE |
---|
6 | } |
---|
7 | killandremove() { |
---|
8 | local PIDFILE=$1 |
---|
9 | kill -9 `cat $PIDFILE` >/dev/null 2>&1 |
---|
10 | remove $PIDFILE |
---|
11 | } |
---|
12 | cat_newline() { |
---|
13 | local PIDFILE=$1 |
---|
14 | cat $PIDFILE |
---|
15 | echo "" |
---|
16 | } |
---|
17 | cat_plain() { |
---|
18 | local PIDFILE=$1 |
---|
19 | cat $PIDFILE |
---|
20 | } |
---|
21 | |
---|
22 | witheach() { |
---|
23 | local CMDPREFIX=$* |
---|
24 | local PIDFILE |
---|
25 | while read PIDFILE; do |
---|
26 | $CMDPREFIX $PIDFILE |
---|
27 | done |
---|
28 | } |
---|
29 | |
---|
30 | # ---------------------------------------- |
---|
31 | |
---|
32 | allpidfiles() { |
---|
33 | ls ~/.arb_tmp/tmp/arb_pids_${USER}_* 2>&1 | grep -v 'No such file' |
---|
34 | } |
---|
35 | sessionpidfiles() { |
---|
36 | local PIDFILE=~/.arb_tmp/tmp/arb_pids_${USER}_${ARB_PID} |
---|
37 | if [ -f $PIDFILE ]; then |
---|
38 | echo $PIDFILE |
---|
39 | fi |
---|
40 | } |
---|
41 | |
---|
42 | pids2processlist() { |
---|
43 | PIDS=`cat -` |
---|
44 | if [ -z "$PIDS" ]; then |
---|
45 | echo "No matching processes detected." |
---|
46 | else |
---|
47 | ps -p $PIDS |
---|
48 | fi |
---|
49 | } |
---|
50 | |
---|
51 | # ---------------------------------------- |
---|
52 | |
---|
53 | show_session() { |
---|
54 | sessionpidfiles | witheach cat_plain | pids2processlist |
---|
55 | } |
---|
56 | session() { |
---|
57 | sessionpidfiles | witheach killandremove |
---|
58 | } |
---|
59 | |
---|
60 | show_all() { |
---|
61 | allpidfiles | witheach cat_plain | pids2processlist |
---|
62 | } |
---|
63 | old() { |
---|
64 | allpidfiles | witheach remove |
---|
65 | } |
---|
66 | killall() { |
---|
67 | allpidfiles | witheach killandremove |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | # ---------------------------------------- |
---|
72 | |
---|
73 | ACTION=$1 |
---|
74 | if [ -z "$ACTION" ]; then |
---|
75 | echo "Usage: arb_clean [action]" |
---|
76 | echo "Known actions are:" |
---|
77 | echo " show_all show process ids of processes that will be killed by action 'killall'" |
---|
78 | echo " show_session show process ids of processes that will be killed by action 'session'" |
---|
79 | echo " session kill all processes running with current ARB_PID" |
---|
80 | echo " old delete old pid-files from /tmp (dont do this while arb is running)" |
---|
81 | echo " killall kill all (current or former) arb processes" |
---|
82 | echo " CAUTION: may act completely wrong and kill various running non-ARB-processes!" |
---|
83 | else |
---|
84 | case $ACTION in |
---|
85 | (session | old | killall | show_all | show_session ) |
---|
86 | $ACTION |
---|
87 | ;; |
---|
88 | ( * ) |
---|
89 | echo "Unknown action '$ACTION'" |
---|
90 | ;; |
---|
91 | esac |
---|
92 | fi |
---|
Note: See
TracBrowser
for help on using the repository browser.