fix: wildfly 36 fetch pid error

This commit is contained in:
ReaJason
2025-11-20 00:36:25 +08:00
parent 05892d4b8b
commit 1cf3c58b7b
+19 -2
View File
@@ -1,2 +1,19 @@
#!/bin/bash
pgrep -f 'Main|jboss-modules.jar' | tr -d '\n'
#!/bin/sh
TARGET_PATTERN='Main|jboss-modules.jar'
for pid_dir in /proc/*; do
if [ -d "$pid_dir" ] && ! [ -z "$(echo "$pid_dir" | sed 's|/proc/||' | grep -E '^[0-9]+$')" ]; then
PID=$(echo "$pid_dir" | sed 's|/proc/||')
CMDLINE_FILE="$pid_dir/cmdline"
if [ -r "$CMDLINE_FILE" ]; then
FULL_CMD=$(sed 's/\x0/ /g' "$CMDLINE_FILE")
if [ -z "$FULL_CMD" ]; then
continue
fi
if echo "$FULL_CMD" | grep -E -q "$TARGET_PATTERN"; then
echo $PID
fi
fi
fi
done