IOException in jline when running a process


(Cay Horstmann) #1

In a request, I create a Process and call start and waitFor on it. When I run the app with sbt run, it crashes and kills the server:

[error] java.io.IOException: Ressource temporairement non disponible
[error] at java.io.FileInputStream.read0(Native Method)
[error] at java.io.FileInputStream.read(FileInputStream.java:207)
[error] at jline.internal.NonBlockingInputStream.read(NonBlockingInputStream.java:245)
[error] at jline.internal.InputStreamReader.read(InputStreamReader.java:257)
[error] at jline.internal.InputStreamReader.read(InputStreamReader.java:194)
[error] at jline.console.ConsoleReader.readCharacter(ConsoleReader.java:2151)
[error] at jline.console.ConsoleReader.readCharacter(ConsoleReader.java:2141)
[error] at play.sbt.PlayConsoleInteractionMode$.waitEOF$1(PlayInteractionMode.scala:63)
[error] at play.sbt.PlayConsoleInteractionMode$.$anonfun$waitForKey$2(PlayInteractionMode.scala:74)
[error] at play.sbt.PlayConsoleInteractionMode$.$anonfun$doWithoutEcho$1(PlayInteractionMode.scala:81)
[error] at play.sbt.PlayConsoleInteractionMode$.$anonfun$doWithoutEcho$1$adapted(PlayInteractionMode.scala:78)
[error] at play.sbt.PlayConsoleInteractionMode$.withConsoleReader(PlayInteractionMode.scala:58)
[error] at play.sbt.PlayConsoleInteractionMode$.doWithoutEcho(PlayInteractionMode.scala:78)
[error] at play.sbt.PlayConsoleInteractionMode$.$anonfun$waitForKey$1(PlayInteractionMode.scala:74)
[error] at play.sbt.PlayConsoleInteractionMode$.$anonfun$waitForKey$1$adapted(PlayInteractionMode.scala:61)
[error] at play.sbt.PlayConsoleInteractionMode$.withConsoleReader(PlayInteractionMode.scala:58)
[error] at play.sbt.PlayConsoleInteractionMode$.waitForKey(PlayInteractionMode.scala:61)
[error] at play.sbt.PlayConsoleInteractionMode$.waitForCancel(PlayInteractionMode.scala:84)
[error] at play.sbt.run.PlayRun$.$anonfun$playRunTask$3(PlayRun.scala:119)
[error] at play.sbt.run.PlayRun$.$anonfun$playRunTask$3$adapted(PlayRun.scala:66)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
INFO - play.core.server.AkkaHttpServer - Stopping server…

The app runs fine when I use sbt dist and deploy it. This used to work fine with sbt run, but it fails with Play 2.6 and 2.7 with JDK8. It is very troublesome because there is now no way to debug this app.

From the stack trace, it seems a jline issue. Is there any workaround?

Thanks,

Cay


(Marcos Pereira) #2

Hey @cayhorstmann,

Can you share the code where the error is happening? Ideally, if you can create an small application that reproduces the problem, it would be even better.

Best.


#3

Hello,
Same problem here. I have these few lines in the method of a Controller

ProcessBuilder pb = new ProcessBuilder("./helloworld.sh");
Logger.info("Start process...");
Process pr = pb.start();
pr.waitFor(10, TimeUnit.SECONDS);
Logger.info("OK");

Here is the output :

[info] application - Start process...
[info] application - OK
java.io.IOException: Ressource temporairement non disponible
        at java.io.FileInputStream.read0(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:207)
        at jline.internal.NonBlockingInputStream.read(NonBlockingInputStream.java:245)
        at jline.internal.InputStreamReader.read(InputStreamReader.java:257)
        at jline.internal.InputStreamReader.read(InputStreamReader.java:194)
        at jline.console.ConsoleReader.readCharacter(ConsoleReader.java:2136)
        at jline.console.ConsoleReader.readCharacter(ConsoleReader.java:2126)
        at play.sbt.PlayConsoleInteractionMode$$anonfun$waitForKey$1.play$sbt$PlayConsoleInteractionMode$$anonfun$$waitEOF$1(PlayInteractionMode.scala:62)
        at play.sbt.PlayConsoleInteractionMode$$anonfun$waitForKey$1$$anonfun$apply$1.apply$mcV$sp(PlayInteractionMode.scala:73)
        at play.sbt.PlayConsoleInteractionMode$$anonfun$doWithoutEcho$1.apply(PlayInteractionMode.scala:80)
        at play.sbt.PlayConsoleInteractionMode$$anonfun$doWithoutEcho$1.apply(PlayInteractionMode.scala:77)
        at play.sbt.PlayConsoleInteractionMode$.withConsoleReader(PlayInteractionMode.scala:57)
        at play.sbt.PlayConsoleInteractionMode$.doWithoutEcho(PlayInteractionMode.scala:77)
        at play.sbt.PlayConsoleInteractionMode$$anonfun$waitForKey$1.apply(PlayInteractionMode.scala:73)
        at play.sbt.PlayConsoleInteractionMode$$anonfun$waitForKey$1.apply(PlayInteractionMode.scala:60)
        at play.sbt.PlayConsoleInteractionMode$.withConsoleReader(PlayInteractionMode.scala:57)
        at play.sbt.PlayConsoleInteractionMode$.waitForKey(PlayInteractionMode.scala:60)
        at play.sbt.PlayConsoleInteractionMode$.waitForCancel(PlayInteractionMode.scala:83)
        at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:123)
        at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)

It was working fine until now. I get back to an old commit where I knew it was working, and I get the same error.


(Tim Moore) #4

This problem was caused by a bug in a recent Linux Kernel update

There are some workarounds described in the comments on this issue:


(Cay Horstmann) #5

Thanks, that would explain why I couldn’t reproduce the issue on my dev machine when I tried to make a simplified example. I am now at kernel 4.18.0-15, and everything works properly as it always did. I very much appreciate the update.