Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39294
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2020-02-14 10:53 -0800 |
| References | <c7b42f97-07e8-4899-85e5-a81153e140b4@googlegroups.com> <r20q9s$5gt$1@dont-email.me> |
| Message-ID | <fe3df469-89b4-4dcd-808e-714891134802@googlegroups.com> (permalink) |
| Subject | Re: running java kills parent shell |
| From | luserdroog <luser.droog@gmail.com> |
On Wednesday, February 12, 2020 at 6:16:07 AM UTC-6, Martin Gregorie wrote:
> On Tue, 11 Feb 2020 19:57:43 -0800, luserdroog wrote:
>
> > I'm using the Java 8 reference implementation. When I run it from
> > cygwin's bash, it runs the program but then it exits the shell. Has
> > anyone encountered this or have any idea how to investigate fixing it?
> > As a workaround, I can spawn a subshell and let that one exit. But I'm
> > not thrilled about having to do this.
>
> Command line example?
>
> I can see ways of using shell so it would do this, but they aren't ways
> that I'd normally use it.
>
I've done a little more investigating. Everything's fine if the program
just does output. eg.
]0;~/cs4500/hw2
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$ cat HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
]0;~/cs4500/hw2
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$ javac HelloWorld.java
]0;~/cs4500/hw2
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$ java HelloWorld
Hello, World
]0;~/cs4500/hw2
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$
But if I use the scanner, then it starts gorping. eg.
]0;~/cs4500/hw2
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$ cat HelloWorld.java
import java.util.Scanner;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
Scanner scan = new Scanner( System.in );
String value = scan.nextLine();
}
}
]0;~/cs4500/hw2
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$ javac HelloWorld.java
]0;~/cs4500/hw2
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$ java HelloWorld
Hello, World
]0;~/cs4500/hw2
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$ exit
Process shell finished
Here, I just typed a single Return key after "Hello, World" was printed.
I did not type "exit", but that's what emacs adds when you do hit ^D.
So it seems like java is closing stdin or somehow stuffing an EOF indicator
into it.
This doesn't happen if I run it from the Windows command line. eg.
C:\cygwin64\home\luser\cs4500\hw2>java HelloWorld
Hello, World
C:\cygwin64\home\luser\cs4500\hw2>
It also doesn't happen if I run it from Xterm. eg.
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$ java HelloWorld
Hello, World
luser@LAPTOP-K627HB8A ~/cs4500/hw2
$
So I guess it's something weird that the Emacs terminal is doing, and
not bash per se.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
running java kills parent shell luserdroog <luser.droog@gmail.com> - 2020-02-11 19:57 -0800
Re: running java kills parent shell Martin Gregorie <martin@mydomain.invalid> - 2020-02-12 12:15 +0000
Re: running java kills parent shell luserdroog <luser.droog@gmail.com> - 2020-02-14 10:53 -0800
Re: running java kills parent shell Martin Gregorie <martin@mydomain.invalid> - 2020-02-14 20:43 +0000
Re: running java kills parent shell luserdroog <luser.droog@gmail.com> - 2020-02-14 13:02 -0800
Re: running java kills parent shell Martin Gregorie <martin@mydomain.invalid> - 2020-02-14 21:46 +0000
Re: running java kills parent shell Arne Vajhøj <arne@vajhoej.dk> - 2020-02-14 19:39 -0500
csiph-web