jline / jline3

JLine is a Java library for handling console input.
Other
1.46k stars 215 forks source link

macOS: com.sun.jna.LastErrorException: [19] Operation not supported by device #128

Closed ghost closed 7 years ago

ghost commented 7 years ago

I am using JLine 3.3.0

When shutting down my shell application, it fails on macOS 10.12.5 (Sierra) with the following exception and stacktrace:

Exception in thread "shell" com.sun.jna.LastErrorException: [19] Operation not supported by device
         at com.sun.jna.Native.invokeVoid(Native Method)
         at com.sun.jna.Function.invoke(Function.java:374)
         at com.sun.jna.Function.invoke(Function.java:323)
         at com.sun.jna.Library$Handler.invoke(Library.java:236)
         at com.sun.proxy.$Proxy49.tcsetattr(Unknown Source)
         at org.jline.terminal.impl.jna.osx.OsXNativePty.setAttr(OsXNativePty.java:72)
         at org.jline.terminal.impl.AbstractPosixTerminal.close(AbstractPosixTerminal.java:74)
         at org.jline.terminal.impl.PosixSysTerminal.close(PosixSysTerminal.java:95)
         at my.Shell.start(Shell.java:91)
         at my.Shell.lambda$run$1(Shell.java:38)
         at java.lang.Thread.run(Thread.java:748)

It works fine on Linux and Windows, only fails on macOS.

ghost commented 7 years ago

Fixed by not closing the LineReader when shutting down: "terminal.reader().close();" was the culprit.