KaiSong-UK opened a new pull request, #18419:
URL: https://github.com/apache/dolphinscheduler/pull/18419
## Description
Fixes #18311.
When `kill -0 <pid>` returns exit code 0 but with non-empty stderr (e.g.,
"Operation not permitted"), `AbstractShell.runCommand()` throws
`ExitCodeException` because it treats any non-empty stderr as an error. This
causes `isProcessAlive()` to catch the exception and return `false`,
incorrectly reporting the process as dead.
## Root Cause
In `AbstractShell.runCommand()`:
```java
if (exitCode != 0 || errMsg.length() > 0) {
throw new ExitCodeException(exitCode, errMsg.toString());
}
```
This throws `ExitCodeException` even when `exitCode == 0` but stderr has
output. `kill -0` on many systems will write "Operation not permitted" to
stderr when called without full permissions, while still returning exit code 0
(process exists).
## Fix
Catch `ExitCodeException` explicitly in `isProcessAlive()` and check the
exit code:
- Exit code 0: process is alive (return `true`)
- Non-zero exit code: process is dead (return `false`)
- Other exceptions: process is dead (return `false`)
## Changes
- Modified 1 file: `ProcessUtils.java`
- Added import for `AbstractShell.ExitCodeException`
- Updated `isProcessAlive()` to handle `ExitCodeException` with exit code
check
Closes #18311
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]