X-Received: by 2002:ad4:4e50:: with SMTP id eb16mr3465886qvb.34.1581706427302; Fri, 14 Feb 2020 10:53:47 -0800 (PST) X-Received: by 2002:a25:4004:: with SMTP id n4mr4166614yba.144.1581706427060; Fri, 14 Feb 2020 10:53:47 -0800 (PST) Path: csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Fri, 14 Feb 2020 10:53:46 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=24.107.176.41; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz NNTP-Posting-Host: 24.107.176.41 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: running java kills parent shell From: luserdroog Injection-Date: Fri, 14 Feb 2020 18:53:47 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Lines: 99 Xref: csiph.com comp.lang.java.programmer:39294 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: >=20 > > 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. >=20 > Command line example? >=20 > I can see ways of using shell so it would do this, but they aren't ways= =20 > that I'd normally use it. >=20 I've done a little more investigating. Everything's fine if the program just does output. eg. =1B]0;~/cs4500/hw2=07 luser@LAPTOP-K627HB8A ~/cs4500/hw2 $ cat HelloWorld.java=20 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } } =1B]0;~/cs4500/hw2=07 luser@LAPTOP-K627HB8A ~/cs4500/hw2 $ javac HelloWorld.java=20 =1B]0;~/cs4500/hw2=07 luser@LAPTOP-K627HB8A ~/cs4500/hw2 $ java HelloWorld Hello, World =1B]0;~/cs4500/hw2=07 luser@LAPTOP-K627HB8A ~/cs4500/hw2 $ But if I use the scanner, then it starts gorping. eg. =1B]0;~/cs4500/hw2=07 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"); =09 Scanner scan =3D new Scanner( System.in ); String value =3D scan.nextLine(); } } =1B]0;~/cs4500/hw2=07 luser@LAPTOP-K627HB8A ~/cs4500/hw2 $ javac HelloWorld.java =1B]0;~/cs4500/hw2=07 luser@LAPTOP-K627HB8A ~/cs4500/hw2 $ java HelloWorld Hello, World =1B]0;~/cs4500/hw2=07 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.=20 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 $=20 So I guess it's something weird that the Emacs terminal is doing, and=20 not bash per se.