Balazs, Thanks for summarizing the behavior of the nifi.cmd stop command on Windows.
As you noted, the Windows implementation of the ProcessHandle class is currently lacking features when it comes to providing argument information. The initial refactoring of the bootstrap and runtime management approach for NiFi 2.0 moved away from the previous implementation based on lock files and custom socket communication. The updated approach avoids a number of issues in the previous implementation, but the stop command functionality on Windows is a gap right now. It would be helpful to summarize your findings in a Jira issue for tracking and additional discussion. The ideal solution would be JVM updates for Windows to provide the command arguments. However, given that the current ProcessHandleImpl [1] for Windows is lacking, we should consider other alternatives. Regards, David Handermann [1] https://github.com/openjdk/jdk/blob/jdk-21%2B35/src/java.base/windows/native/libjava/ProcessHandleImpl_win.c On Mon, Jan 13, 2025 at 4:37 AM Balázs Gerner <balazsger...@gmail.com> wrote: > > Dear Apache NiFi Community, > > I am reaching out to report a potential bug in Apache NiFi 2.0 (and likely > 2.1) related to stopping the application on Windows. During my testing on > Windows Server 2025 (Version 24H2, OS Build 26100.2314), I encountered an > issue where the 'bin/nifi.cmd start' command successfully starts NiFi, but > the 'bin/nifi.cmd stop' command fails. The following error is displayed > during the stop attempt: > org.apache.nifi.bootstrap.Command Application Process not running. > > Upon investigation, I found that the issue seems to stem from the bootstrap > code responsible for looking up the application process. Specifically, the > problematic code can be found here: > StandardProcessHandleProvider.java#L73 > <https://github.com/apache/nifi/blob/6b6e8d6f785ccb9f61fd4e8599dcdc855dd5965f/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/command/process/StandardProcessHandleProvider.java#L73> > > At this line, the process arguments are expected to be present but are > actually empty on Windows, causing the application process handle to remain > unfound. Notably, this behavior is specific to Windows, as the same code > works as expected on Linux and macOS. > > I also tested this issue using two different JDKs—Zulu 21 JDK and OpenJDK > 21—and observed the same behavior in both cases. > > A potentially related issue is described in JDK-8176725 > <https://bugs.openjdk.org/browse/JDK-8176725>, where comments mention that > certain behaviors are platform-dependent. This could provide context for > the problem I’m experiencing. > > Lastly, I would like to ask the community: > Has anyone tested Apache NiFi 2.0 on different Windows editions (Home, Pro, > Server)? If so, do the start/stop commands work as expected in those > environments? > > Thank you for your time and any insights you can provide. I am happy to > assist further with debugging or testing if needed. > > Best regards, > Balázs Gerner