File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed
Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ # -*-Shell-script-*-
2+
3+ # Make sure umask is sane
4+ umask 022
5+
6+ # /usr/libexec/audit/audit-functions
7+
8+ # killproc {program} [-signal]
9+ killproc ()
10+ {
11+ local daemon=" $1 "
12+ local sig=
13+ [ -n " ${2:- } " ] && sig=$2
14+
15+ # This matches src/auditd.c
16+ local pid_file=" /var/run/auditd.pid"
17+ local pid_dir=$( dirname $pid_file )
18+
19+ if [ ! -d " $pid_dir " ] ; then
20+ return 4
21+ fi
22+
23+ local pid=
24+ if [ -f " $pid_file " ] ; then
25+ # pid file exists, use it
26+ while : ; do
27+ read line
28+ [ -z " $line " ] && break
29+ for p in $line ; do
30+ # pid is numeric and corresponds to a process
31+ if [ -z " ${p// [0-9]/ } " ] && [ -d " /proc/$p " ] ; then
32+ d=$( cat " /proc/$p /comm" )
33+ if [ " $d " = " $daemon " ] ; then
34+ pid=" $p "
35+ break
36+ fi
37+ fi
38+ done
39+ done < " $pid_file "
40+ else
41+ # need to search /proc
42+ p=$( pidof " $daemon " )
43+ if [ -n " $p " ] ; then
44+ pid=" $p "
45+ fi
46+ fi
47+
48+ # At this point we should have a pid or the process is dead
49+ if [ -n " $pid " ] && [ -n " $sig " ] ; then
50+ kill " $sig " " $pid " > /dev/null 2>&1
51+ fi
52+ }
You can’t perform that action at this time.
0 commit comments