Program doesn't shut down properly in some cases on windows
lhns opened this issue · comments
I have noticed that in some cases the program doesn't shut down properly on windows when using an effect framework like cats-effect for scala.
I made a simple java program to demonstrate the weird behaviour.
When I try to stop the programm normally (SIGINT) it just hangs. The main thread is not stopped and no shutdown hooks are run. This doesn't happen when I don't mount a filesystem or unmount it before shutting down. It seems to be related to the exit signals since System.exit does not cause this behaviour.
I have not tried another platform besides windows.
Maybe there is some kind of signal handler in winsfp that kills the java threads or something similar.
I have not yet found any workaround.
import ru.serce.jnrfuse.FuseStubFS;
import java.nio.file.Paths;
public class StopTest {
public static void main(String[] args) {
Runtime.getRuntime().addShutdownHook(
new Thread(() -> System.out.println("SHUTDOWN"))
);
new FuseStubFS().mount(Paths.get("J:\\"), false);
while (true) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}