15 lines
652 B
Bash
Executable File
15 lines
652 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Stop any running instance.
|
|
#
|
|
# Match a real JVM whose command line contains this application's main class, and exclude this
|
|
# shell and its parent explicitly. A bare grep for the class name is not enough: when the
|
|
# calling shell's own command line contains the class name - which it does whenever you paste a
|
|
# here-doc - the grep matches the shell and kills it.
|
|
set -eu
|
|
self=$$; parent=${PPID:-0}
|
|
for pid in $(ps -eo pid,ppid,comm,args | awk -v s="$self" -v p="$parent" \
|
|
'$1 != s && $1 != p && $3 ~ /^java/ && $0 ~ /com\.ankurm\.ssrf\.SsrfDemoApplication/ {print $1}'); do
|
|
kill -9 "$pid" 2>/dev/null || true
|
|
done
|
|
sleep 1
|