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

"java.net.BindException: Address already in use..." caused by orphaned java process #4

Closed
jtcbrule opened this issue Jul 28, 2014 · 2 comments

Comments

@jtcbrule
Copy link

I'm running lein-gorilla 0.3.1 on cygwin. Executing:

$ lein gorilla

from bash spawns a new bash process, which spawns a bash sub-process, which spawns a java subprocess, which spawns another java subprocess.

bash.exe (original, from which lein gorilla is executed)
bash.exe (new)
- bash.exe (subprocess)
- - java.exe
- - - java.exe

Ctrl+C kills the new bash.exe, the subprocess bash, and the first java.exe, but orphans the last java process.

This becomes a problem when trying to restart gorilla:

$ lein gorilla
Gorilla-REPL: 0.3.1
Started nREPL server on port 53008
Exception in thread "main" java.net.BindException: Address already in use: bind, compiling:(C:\cygwin\tmp\form-init8307404900158704503.clj:1:102)
        at clojure.lang.Compiler.load(Compiler.java:7142)
        at clojure.lang.Compiler.loadFile(Compiler.java:7086)
        at clojure.main$load_script.invoke(main.clj:274)
        at clojure.main$init_opt.invoke(main.clj:279)
        at clojure.main$initialize.invoke(main.clj:307)
        at clojure.main$null_opt.invoke(main.clj:342)
        at clojure.main$main.doInvoke(main.clj:420)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:383)
        at clojure.lang.AFn.applyToHelper(AFn.java:156)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)
Caused by: java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at org.httpkit.server.HttpServer.<init>(HttpServer.java:42)
        at org.httpkit.server$run_server.invoke(server.clj:8)
        at gorilla_repl.core$run_gorilla_server.invoke(core.clj:114)
        at user$eval3284.invoke(form-init8307404900158704503.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:6703)
        at clojure.lang.Compiler.eval(Compiler.java:6693)
        at clojure.lang.Compiler.load(Compiler.java:7130)
        ... 11 more

Manually killing the orphaned java.exe fixes this problem.

@JonyEpsilon
Copy link
Owner

Hmmm, that's not very good! I don't really know enough about how Leiningen spawns processes on Windows to even know how to begin fixing this, but I'll do a bit of Googling :-)

@jtcbrule
Copy link
Author

A little more experimentation suggests that this is a leiningen/cygwin problem and not a gorilla problem; an ordinary "$ lein repl" invocation spawn the same tower of processes, and a Ctrl-C still orphans a java process.

I never noticed this since a) I almost always close a repl with Ctrl-D or (exit), and b) it's still possible to start a new repl without killing the orphaned java process

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

No branches or pull requests

2 participants