Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParentProcessWatcher is not working properly on macOS #2488

Closed
testforstephen opened this issue May 31, 2022 · 1 comment · Fixed by eclipse-jdtls/eclipse.jdt.ls#2115
Closed
Labels
Milestone

Comments

@testforstephen
Copy link
Collaborator

OS: macOS Catalina
vscode-java: 1.6.0

Open a Java project in VS Code, wait for the projects to be imported, and then click x button to close VS Code Window. Java extension is supposed to detect parent process exit and shutdown itself. Actually the log shows the ParentProcessWatcher didn't work.

!ENTRY org.eclipse.jdt.ls.core 4 0 2022-05-31 21:04:11.286
!MESSAGE Cannot run program "kill": error=316, posix_spawn failed
!STACK 0
java.io.IOException: Cannot run program "kill": error=316, posix_spawn failed
	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
	at java.base/java.lang.Runtime.exec(Unknown Source)
	at java.base/java.lang.Runtime.exec(Unknown Source)
	at java.base/java.lang.Runtime.exec(Unknown Source)
	at org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.parentProcessStillRunning(ParentProcessWatcher.java:77)
	at org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.run(ParentProcessWatcher.java:49)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: error=316, posix_spawn failed
	at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(Unknown Source)
	at java.base/java.lang.ProcessImpl.start(Unknown Source)
	... 13 more
@testforstephen
Copy link
Collaborator Author

An alternative approach is to use JDK ProcessHandle API. It supports getting a ProcessHandle from a pid, and listening at its exit event via ProcessHandle.onExit().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants