Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #12873

[Windows] Any way to distinguish ^C Induced EOF from ^Z EOF?

From Jan Burse <janburse@fastmail.fm>
Newsgroups comp.lang.java.programmer
Subject [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF?
Date 2012-03-11 21:57 +0100
Organization albasani.net
Message-ID <jjj3ke$jev$1@news.albasani.net> (permalink)

Show all headers | View raw


Dear All,

Just running the following test program:

         CtrlCRunner ctrl = new CtrlCRunner();
         ctrl.installCtrlC(
                 new Runnable() {
                     public void run() {
                         /* do nothing ! */
                     }
                 }
         );
         FileInputStream fs = new FileInputStream(FileDescriptor.in);
         byte[] buf = new byte[256];
         for (;;) {
             System.out.print("test: ");
             int len = fs.read(buf);
             String str = new String(buf,0,Math.max(0,len));
             System.out.println("len = "+len+", buf = "+str+", 
buf[0]="+buf[0]);
             if ("exit".equals(str.trim())) break;
         }
         ctrl.deinstallCtrlC();

Noticed that ^C and ^Z both deliver EOF.

When pressing ^C

	test: len = -1, buf = , buf[0]=0

When pressing ^Z and ENTER:

	test: ^Z
	len = -1, buf = , buf[0]=0

How could I distinguish the two in Java?

Best Regards

BTW: It does not happen on Linux and Mac
OS with ^C and ^D, I only see this happen
currently on Windows 7.

Sounds similar to the following problem:
Inconsistent raw_input behavior after Ctrl-C
http://www.gossamer-threads.com/lists/python/python/781893

Back to comp.lang.java.programmer | Previous | NextNext in thread | Find similar


Thread

[Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-11 21:57 +0100
  Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-11 22:10 +0100
  Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-11 17:28 -0400
    Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-11 22:49 +0100
      Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-11 18:13 -0400
        Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-11 23:23 +0100
          Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-11 18:35 -0400
          Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? markspace <-@.> - 2012-03-11 15:51 -0700
            Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-12 10:58 +0100
              Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Lew <noone@lewscanon.com> - 2012-03-12 07:38 -0700
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-12 20:43 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 16:01 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-03-12 17:28 -0500
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 00:33 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Lew <lewbloch@gmail.com> - 2012-03-12 16:50 -0700
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 00:56 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 20:03 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 01:05 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 20:53 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 14:06 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 14:13 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-13 11:36 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 17:48 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 17:51 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-13 13:06 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 19:56 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 01:05 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Lew <lewbloch@gmail.com> - 2012-03-12 17:23 -0700
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 20:51 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Martin Gregorie <martin@address-in-sig.invalid> - 2012-03-13 02:33 +0000
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Patricia Shanahan <pats@acm.org> - 2012-03-12 20:39 -0700
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 14:17 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-13 11:38 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-03-12 21:59 -0500
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 14:20 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-13 11:28 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 17:42 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-13 13:16 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 18:17 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 18:19 +0100
              Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Silvio Bierman <silvio@moc.com> - 2012-03-12 16:21 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-12 20:35 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Robert Klemme <shortcutter@googlemail.com> - 2012-03-12 22:49 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Silvio Bierman <silvio@moc.com> - 2012-03-13 14:10 +0100
              Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 13:49 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-12 20:16 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-03-12 14:42 -0500
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-12 20:46 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 16:09 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 16:07 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-12 21:27 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 16:52 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-12 22:39 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-12 17:56 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Robert Klemme <shortcutter@googlemail.com> - 2012-03-12 23:02 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 00:18 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 00:19 +0100
  Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Steven Simpson <ss@domain.invalid> - 2012-03-13 10:28 +0000
    Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 14:11 +0100
      Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-13 11:41 -0400
        Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 17:43 +0100
          Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-13 13:03 -0400
            Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 18:20 +0100
              Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-13 13:36 -0400
              Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-03-13 12:42 -0500
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 18:51 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 18:51 +0100
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Arne Vajhøj <arne@vajhoej.dk> - 2012-03-13 19:53 -0400
                Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-14 01:21 +0100
      Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Steven Simpson <ss@domain.invalid> - 2012-03-13 17:26 +0000
        Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse <janburse@fastmail.fm> - 2012-03-13 18:44 +0100

csiph-web