Repository navigation
Conversation
A directory with a start.log but no pid file was used by an earlier version of the script, and --stop found its node by the jar name alone, so it also stopped nodes with the same jar name in other directories. Pick the node whose working directory is the current directory, read from /proc on Linux or with lsof on macOS. When neither is available, exit with an error that asks for the process id in the pid file.
3for
reviewed
Oct 30, 2026
3for
reviewed
Oct 30, 2026
The pid file path matched only the jar name, so a recorded id reused by a node that runs the same jar from another directory would have stopped that node. A recorded process whose working directory reads as another directory is now taken as a stopped node and the pid file is emptied; one whose directory cannot be read keeps the pid file and is stopped as before. Without a pid file, a process whose working directory could not be read was skipped silently, so --stop could report the node stopped while it was still running. If this user can signal such a process, --stop and restart now end with an error on stderr; a process this user cannot signal is left running with a warning.
3for
reviewed
Oct 30, 2026
3for
reviewed
Oct 30, 2026
stopService ended with sleep 5 and returned success even when the node was still running: a process this user cannot signal made every kill fail until the timeout, and a restart then started another node and wrote its id over the pid file of the running one. A failed signal now counts while the process still exists, and a node still running after SIGKILL fails too; both report an error on stderr and return 2, which ends --stop with that status and stops a restart before it starts a node. A return of 1 still means no node was ever started from the directory, so --run starts the node as before. shell.md now states that the directory check needs a readable working directory, and that a pid file whose process cannot be inspected is trusted as recorded.
3for
approved these changes
Oct 30, 2026
halibobo1205
reviewed
Nov 2, 2026
Compare a process's working directory with the current directory by device and inode instead of by path, so a directory entered with a different letter case or through a symlink still matches. A deleted working directory now counts as unreadable: on Linux its path ends in " (deleted)", and lsof keeps its last path, which counts only while it still leads to the inode lsof reports. Without a pid file, a process that can be signalled but whose directory cannot be read is skipped once it no longer runs the jar, so a zombie after SIGKILL is not reported as unreadable. The pid-file warning names the directory the recorded process runs from instead of saying the node has stopped. Shorten the shell.md description of --stop, and note that only a process this user can signal makes it fail.
bladehan1
approved these changes
Nov 3, 2026
halibobo1205
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
start.sh --stopnow stops only the node started from the current directory: a matching process counts only when its working directory is the current directory (read from/proc/<pid>/cwdon Linux or withlsofon macOS, compared by device and inode).start.shprocessDir/matchDirPid: check the working directory on both the pid-file path and the path without a pid file (a node started by an earlier script). A process running from another directory is left running, with a warning when it is the one in the pid file.--stopfails and asks for the id in the pid file if this user can signal the process, otherwise it only warns. Zombies are skipped.stopServicereturns 2 when the node cannot be stopped (killfails on a live process, or it survivesSIGKILL);--stopexits 2 and a restart starts nothing.shell.md: describe the directory check and its limits.Why are these changes required?
Since #7003, a directory with
start.logbut no pid file still finds its node by jar name across the whole machine, so--stopor a restart there also stops same-named nodes in other directories, even when its own node is not running. The pid-file path checks only the jar name, so a reused id can stop another directory's node. AndstopServicereturns success when the node cannot be stopped, so a restart starts a second node and overwrites the pid file.The node is started from its directory and the JVM keeps that working directory, so the working directory tells the nodes apart.
This PR has been tested by:
-jar <test jar>from separate directories:lsof): 302 checks pass, 78 of them on--stop.eclipse-temurin:17-jdk,shis dash): 81--stopchecks with default capabilities and 78 withSYS_PTRACE, plus 35 general checks, all pass.sh start.sh,SIGKILLtimeout, a node restarted by a supervisor, zombie.bash -n start.sh;shellcheckreports nothing new.--stopin A--stopin A--stopexits 0, restart starts another node--stopexits 2, restart starts nothingFollow up
None.
Extra details
pgrepandpkillcannot filter by working directory, hence/procandlsof; a lock file or systemd units would change how nodes are deployed.pwd -Pkeeps the letter case typed incdon case-insensitive APFS, andlsofkeeps the last path of a deleted directory.