Skip to content

Commit 83a2a13

Browse files
committed
check the success when create jstack_file_dir
1 parent fe43dcb commit 83a2a13

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

docs/java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Output control:
101101
default from all java process.
102102
-c, --count <num> set the thread count to show, default is 5.
103103
-a, --append-file <file> specifies the file to append output as log.
104-
-S, --jstack-file-dir <path> specifies the dir for storing jstack output files, and keep files.
104+
-S, --jstack-file-dir <path> specifies the directory for storing jstack output files, and keep files.
105105
default store jstack output files at tmp dir, and auto remove after run.
106106
use this option to keep files so as to review jstack later.
107107
delay the delay between updates in seconds.

show-busy-java-threads

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Output control:
8787
default from all java process.
8888
-c, --count <num> set the thread count to show, default is 5.
8989
-a, --append-file <file> specifies the file to append output as log.
90-
-S, --jstack-file-dir <path> specifies the dir for storing jstack output files, and keep files.
90+
-S, --jstack-file-dir <path> specifies the directory for storing jstack output files, and keep files.
9191
default store jstack output files at tmp dir, and auto remove after run.
9292
use this option to keep files so as to review jstack later.
9393
delay the delay between updates in seconds.
@@ -189,9 +189,13 @@ count=${count:-5}
189189
use_ps=${use_ps:-false}
190190
top_delay=${top_delay:-0.5}
191191

192-
if [ -n "$jstack_file_dir" -a -e "$jstack_file_dir" ]; then
193-
[ ! -d "$jstack_file_dir" ] && fatal "Error: $jstack_file_dir(specified by option -S, the dir for storing jstack output files) exists but is not a directory!"
194-
[ ! -w "$jstack_file_dir" ] && fatal "Error: directory $jstack_file_dir(specified by option -S, the dir for storing jstack output files) exists but is not writable!"
192+
if [ -n "$jstack_file_dir" ]; then
193+
if [ -e "$jstack_file_dir" ]; then
194+
[ ! -d "$jstack_file_dir" ] && fatal "Error: $jstack_file_dir(specified by option -S, for storing jstack output files) exists but is not a directory!"
195+
[ ! -w "$jstack_file_dir" ] && fatal "Error: directory $jstack_file_dir(specified by option -S, for storing jstack output files) exists but is not writable!"
196+
else
197+
mkdir -p "$jstack_file_dir" && fatal "Error: fail to create directory $jstack_file_dir(specified by option -S, for storing jstack output files)!"
198+
fi
195199
fi
196200

197201
update_delay=${1:-0}
@@ -224,7 +228,6 @@ readonly tmp_store_dir="/tmp/${uuid}"
224228
mkdir -p "$tmp_store_dir"
225229

226230
if [ -n "$jstack_file_dir" ]; then
227-
mkdir -p "$jstack_file_dir"
228231
readonly jstack_file_path_prefix="$jstack_file_dir/jstack_${run_timestamp}_"
229232
else
230233
readonly jstack_file_path_prefix="$tmp_store_dir/jstack_${run_timestamp}_"

0 commit comments

Comments
 (0)