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

Console.readLine broken after running a Process with connectInput=true #7963

Closed
scabug opened this issue Nov 10, 2013 · 12 comments · Fixed by scala/scala#8269
Closed

Console.readLine broken after running a Process with connectInput=true #7963

scabug opened this issue Nov 10, 2013 · 12 comments · Fixed by scala/scala#8269

Comments

@scabug
Copy link

scabug commented Nov 10, 2013

// ConnectInput.scala
import scala.sys.process._
object FooApp extends App {
  "ls -l".run(true).exitValue()
  Console.readLine("Foo bar ? ")
}

When running this code, one needs to press enter twice in order to exit the process. This problem does not occur when using run(false) instead, so it must somehow be related to how the standard input is connected.

(still got the issue by using scala.io.ReadStdin instead of Console).

I've found a similar issue described here => http://stackoverflow.com/questions/15774987/scala-process-exits-but-doesnt-clean-up-threads/15817760#15817760

@scabug
Copy link
Author

scabug commented Nov 10, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7963?orig=1
Reporter: legendre
Affected Versions: 2.10.2, 2.11.0-M4, 2.11.0-M7, 2.11.0, 2.12.0-M1

@scabug
Copy link
Author

scabug commented Oct 24, 2014

legendre said:
Now that #8768 has been fixed, could someone check if this issue is still valid ? I can't test it since there is no release for the 2.12.0-M1 yet.
Thanks.

@scabug
Copy link
Author

scabug commented Oct 25, 2014

@som-snytt said:

import scala.sys.process._

object Test extends App {
  "ls".run(true).exitValue()
  val line = io.StdIn.readLine("Foo bar ? ")
  Console println s"[$line]"
}

Foo bar ? bye
Exception in thread "Thread-0" java.io.IOException: Stream closed
	at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
	at java.io.OutputStream.write(OutputStream.java:116)
	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
	at java.io.FilterOutputStream.close(FilterOutputStream.java:158)
	at scala.sys.process.BasicIO$$anonfun$input$1.apply(BasicIO.scala:200)
	at scala.sys.process.BasicIO$$anonfun$input$1.apply(BasicIO.scala:198)
	at scala.sys.process.ProcessBuilderImpl$Simple$$anonfun$2.apply$mcV$sp(ProcessBuilderImpl.scala:73)
	at scala.sys.process.ProcessImpl$Spawn$$anon$1.run(ProcessImpl.scala:23)

[]

@scabug
Copy link
Author

scabug commented Mar 6, 2015

legendre said (edited on Mar 6, 2015 5:05:37 PM UTC):
@A. P. Marki => I also have the same exception that comes from nowhere now....

@jrudolph
Copy link
Member

I analyzed the issue in sbt/sbt#3737 (comment). We basically need a port of the fix of this old sbt issue: sbt/sbt#327.

@jrudolph
Copy link
Member

(Not so sure about "good first issue" and "quickfix", though ;)

@som-snytt
Copy link

I remember thinking that upgrading to the Java 7 API could happen after sys.process became a module. Consumers could benefit from a shorter release cycle for the module.

@SethTisue
Copy link
Member

SethTisue commented Feb 15, 2018

(I do think it's a "good first issue" in the sense that it doesn't involve compiler internals or juggling a lot of competing concerns, it's a focused thing that can be tackled in isolation. There are precious few open issues in scala/bug that are actually easy and quick.)

@som-snytt
Copy link

@SethTisue you need a label for "good GSOC issue."

@jrudolph
Copy link
Member

(I do think it's a "good first issue" in the sense that it doesn't involve compiler internals or juggling a lot of competing concerns, it's a focused thing that can be tackled in isolation. There are precious few open issues in scala/bug that are actually easy and quick.)

Haha, I see, everything is relative I guess.

@SethTisue
Copy link
Member

in 2.13, scala.sys will become its own module, at which point this could be addressed if someone cares to. closing since scala.sys issues will no longer be tracked here in scala/bug. I've made a "module:scala.sys" label so we can find relevant issues once the module has its own repo

@SethTisue SethTisue removed this from the Backlog milestone Mar 2, 2018
@SethTisue SethTisue reopened this Nov 21, 2018
@mshibuya
Copy link

I'll tackle on this for OSS Hackathon@ScalaMatsuri 2019, though I'm not sure whether I can finish...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment