Path: csiph.com!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: [Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Date: Sun, 11 Mar 2012 22:49:55 +0100 Organization: albasani.net Lines: 50 Message-ID: References: <4f5d18ef$0$291$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.albasani.net XYoMmc53uvqhGQYkYpK1GiRdXpb5YdB5BInevXMhP0ksGvDzWpflI7+4TiAk50q8lqMsELO/7LxnyCifd7o7CbfvKmMZFW5Gs760OPDc5ZGwVf6ihT+OcQYL/LO47Ahb NNTP-Posting-Date: Sun, 11 Mar 2012 21:49:55 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="TIgDWy4C+OCuKVlvSvFieZkqmFlSmKRAgJBDxt+lc3vl1qsmdw6BDpC78IHVJEAyGucFw1COW0D44mo8Jz0HImnFCXcrVLdPmcdGzdIwV7L0JSBk9nQixpFBHZw0QsgC"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Firefox/10.0.2 SeaMonkey/2.7.2 In-Reply-To: <4f5d18ef$0$291$14726298@news.sunsite.dk> Cancel-Lock: sha1:tASJKeO+uHk8ZhDcqOeldbyO3p4= Xref: csiph.com comp.lang.java.programmer:12877 Arne Vajhøj schrieb: > That type of stuff is very OS specific. > > I will (again) suggest using JNI to get the specific > behavior that you desire. > > Java IO is just for the 98% of cases. > > Arne > When I raise the signal manually, for example as follows: new Thread() { public void run() { try { Thread.sleep(2000); } catch (InterruptedException x) { /* */ } Signal.raise(new Signal("INT")); } }.start(); Then the EOF does not happen. So it is not a problem of the Java dispatcher, more of the ReadFile operation. I am open to JNI, and also to JNA. Best would be if there is something out of the box. It could be fixed, if one would have access to GetLastError. Namely the MS docs do write: "Characters can be read from the console input buffer by using ReadFile with a handle to console input. The console mode determines the exact behavior of the ReadFile function. By default, the console mode is ENABLE_LINE_INPUT, which indicates that ReadFile should read until it reaches a carriage return. If you press Ctrl+C, the call succeeds, but GetLastError returns ERROR_OPERATION_ABORTED. For more information, see CreateFile." http://msdn.microsoft.com/en-us/library/windows/desktop/aa365467%28v=vs.85%29.aspx Such a patch seems to be also done here: [Chicken-hackers] [PATCH] handle SIGINT correctly in csi on windows http://www.mail-archive.com/chicken-hackers@nongnu.org/msg01846.html Bye