Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2012-04-25 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
-+--
  Reporter:  FalconNL|  Owner:
  Type:  bug | Status:  new   
  Priority:  normal  |  Milestone:  7.6.1 
 Component:  libraries/base  |Version:  6.8.2 
Resolution:  |   Keywords:  hsetbuffering buffering buffer
Os:  Windows |   Architecture:  x86   
   Failure:  None/Unknown| Difficulty:  Unknown   
  Testcase:  |  Blockedby:
  Blocking:  |Related:
-+--

Comment(by pcapriotti):

 I've spent some time looking into this. To summarize the situation:

  1. setting a console handle to unbuffered mode breaks ghci input with
 cmd.exe and cygwin
  2. unbuffered console input doesn't work properly with newline characters
 when using the POSIX API
  3. I tried the simple C program above, and it works fine, but ESC
 characters (as in the original issue) are still not detected. Maybe the
 ESC key has some special behavior? Ctrl+[ does send a '\ESC' character
 with msys, but not with cmd.exe.

 Possible solutions:

  * The best solution still seems to be to rewrite the whole IO subsystem
 using the Windows API. Is anyone working on this already, perhaps?
  * Alternatively, it might be possible to replace calls to `read` and
 `write` with `ReadFile` and `WriteFile` respectively. I think we need to
 replace both to ensure that buffering still works. The problem with this
 is that we need to carry around the windows handle, to avoid using
 `_get_osfhandle` at every call to `read`.

 I'm not sure if any of those solutions would address problem 1 above.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:37
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2011-07-06 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
-+--
  Reporter:  FalconNL|  Owner:
  Type:  bug | Status:  new   
  Priority:  low |  Milestone:  7.2.1 
 Component:  libraries/base  |Version:  6.8.2 
Resolution:  |   Keywords:  hsetbuffering buffering buffer
  Testcase:  |  Blockedby:
Difficulty:  Unknown | Os:  Windows   
  Blocking:  |   Architecture:  x86   
   Failure:  None/Unknown|  
-+--
Changes (by romildo):

 * cc: malaquias@… (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:34
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2011-06-09 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
-+--
  Reporter:  FalconNL|  Owner:
  Type:  bug | Status:  new   
  Priority:  low |  Milestone:  7.2.1 
 Component:  libraries/base  |Version:  6.8.2 
Resolution:  |   Keywords:  hsetbuffering buffering buffer
  Testcase:  |  Blockedby:
Difficulty:  Unknown | Os:  Windows   
  Blocking:  |   Architecture:  x86   
   Failure:  None/Unknown|  
-+--
Changes (by Artyom.Kazak):

 * cc: Artyom.Kazak@… (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:33
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2010-09-28 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
-+--
  Reporter:  FalconNL|  Owner:
  Type:  bug | Status:  new   
  Priority:  low |  Milestone:  7.0.1 
 Component:  libraries/base  |Version:  6.8.2 
Resolution:  |   Keywords:  hsetbuffering buffering buffer
  Testcase:  |  Blockedby:
Difficulty:  Unknown | Os:  Windows   
  Blocking:  |   Architecture:  x86   
   Failure:  None/Unknown|  
-+--
Changes (by ddiaz):

 * cc: ddiaz (added)


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:30
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2009-11-21 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
-+--
  Reporter:  FalconNL|  Owner:
  Type:  bug | Status:  new   
  Priority:  normal  |  Milestone:  6.12 branch   
 Component:  libraries/base  |Version:  6.8.2 
Resolution:  |   Keywords:  hsetbuffering buffering buffer
Difficulty:  Unknown | Os:  Windows   
  Testcase:  |   Architecture:  x86   
   Failure:  None/Unknown|  
-+--
Changes (by igloo):

  * failure:  = None/Unknown
  * milestone:  6.12.1 = 6.12 branch

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:27
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2009-06-01 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
---+
Reporter:  FalconNL|Owner: 
Type:  bug |   Status:  new
Priority:  normal  |Milestone:  6.12.1 
   Component:  libraries/base  |  Version:  6.8.2  
Severity:  normal  |   Resolution: 
Keywords:  hsetbuffering buffering buffer  |   Difficulty:  Unknown
Testcase:  |   Os:  Windows
Architecture:  x86 |  
---+
Changes (by simonmar):

  * priority:  high = normal

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:26
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2009-04-11 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
---+
Reporter:  FalconNL|Owner: 
Type:  bug |   Status:  new
Priority:  high|Milestone:  6.12.1 
   Component:  libraries/base  |  Version:  6.8.2  
Severity:  normal  |   Resolution: 
Keywords:  hsetbuffering buffering buffer  |   Difficulty:  Unknown
Testcase:  |   Os:  Windows
Architecture:  x86 |  
---+
Changes (by igloo):

  * status:  reopened = new
  * owner:  igloo =
  * milestone:  6.10.2 = 6.12.1

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:25
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2009-03-06 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
---+
Reporter:  FalconNL|Owner:  igloo  
Type:  merge   |   Status:  new
Priority:  high|Milestone:  6.10.2 
   Component:  libraries/base  |  Version:  6.8.2  
Severity:  normal  |   Resolution: 
Keywords:  hsetbuffering buffering buffer  |   Difficulty:  Unknown
Testcase:  |   Os:  Windows
Architecture:  x86 |  
---+
Changes (by simonmar):

  * owner:  simonmar = igloo
  * type:  bug = merge

Comment:

 Patch applied:

 {{{
 Thu Mar  5 03:33:23 PST 2009  Simon Marlow marlo...@gmail.com
   * FIX #2189: re-enabled cooked mode for Console-connected Handles on
 Windows
 }}}

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:22
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2009-03-06 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
---+
Reporter:  FalconNL|Owner:  igloo  
Type:  merge   |   Status:  closed 
Priority:  high|Milestone:  6.10.2 
   Component:  libraries/base  |  Version:  6.8.2  
Severity:  normal  |   Resolution:  fixed  
Keywords:  hsetbuffering buffering buffer  |   Difficulty:  Unknown
Testcase:  |   Os:  Windows
Architecture:  x86 |  
---+
Changes (by igloo):

  * status:  new = closed
  * resolution:  = fixed

Comment:

 Merged

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:23
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2009-02-25 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
---+
Reporter:  FalconNL|Owner: 
Type:  bug |   Status:  new
Priority:  normal  |Milestone:  6.10.2 
   Component:  libraries/base  |  Version:  6.8.2  
Severity:  normal  |   Resolution: 
Keywords:  hsetbuffering buffering buffer  |   Difficulty:  Unknown
Testcase:  |   Os:  Windows
Architecture:  x86 |  
---+
Comment (by simonmar):

 Replying to [comment:17 sof]:
  I believe I have a trivial fix for this, and can forward for testing 
 commit, if still of interest.

 Yes please!

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:19
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2009-02-25 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
---+
Reporter:  FalconNL|Owner: 
Type:  bug |   Status:  new
Priority:  normal  |Milestone:  6.10.2 
   Component:  libraries/base  |  Version:  6.8.2  
Severity:  normal  |   Resolution: 
Keywords:  hsetbuffering buffering buffer  |   Difficulty:  Unknown
Testcase:  |   Os:  Windows
Architecture:  x86 |  
---+
Comment (by sof):

 ok, not futzing with making this a proper patch:

 {{{
 --- old-base/cbits/consUtils.c  2009-02-25 10:06:10.631125000 -0800
 +++ new-base/cbits/consUtils.c  2009-02-25 10:06:10.64675 -0800
 @@ -25,10 +25,13 @@
  DWORD flgs = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT;

  if ( (h = (HANDLE)_get_osfhandle(fd)) != INVALID_HANDLE_VALUE ) {
 +  /* Only for console-connected Handles */
 +  if ( GetFileType(h) == FILE_TYPE_CHAR ) {
 if ( GetConsoleMode(h,st) 
 -SetConsoleMode(h, cooked ? (st | ENABLE_LINE_INPUT) : st 
 ~flgs) ) {
 +SetConsoleMode(h, cooked ? (st | flgs) : st  ~flgs)  ) {
 return 0;
 }
 +  }
  }
  return -1;
  }

 --- old-base/GHC/Handle.hs  2009-02-25 10:06:10.631125000 -0800
 +++ new-base/GHC/Handle.hs  2009-02-25 10:06:10.64675 -0800
 @@ -1374,13 +1374,10 @@
is_tty - fdIsTTY (haFD handle_)
when (is_tty  isReadableHandleType (haType handle_)) $
  case mode of
 -#ifndef mingw32_HOST_OS
 --- 'raw' mode under win32 is a bit too specialised (and
 troublesome
 --- for most common uses), so simply disable its use here.
 +   -- Note: we used to disable 'cooked' mode setting
 +   -- for mingw / win32 here, but it is now back on (and
 well
 +   -- behaved for Console-connected Handles.)
NoBuffering - setCooked (haFD handle_) False
 -#else
 -  NoBuffering - return ()
 -#endif
_   - setCooked (haFD handle_) True

-- throw away spare buffers, they might be the wrong size
 }}}

 i.e., reliably (un)setting the line buffering flags of the underlying
 Console handle (if there's one) takes care of this.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:20
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2009-02-24 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
---+
Reporter:  FalconNL|Owner: 
Type:  bug |   Status:  new
Priority:  normal  |Milestone:  6.10.2 
   Component:  libraries/base  |  Version:  6.8.2  
Severity:  normal  |   Resolution: 
Keywords:  hsetbuffering buffering buffer  |   Difficulty:  Unknown
Testcase:  |   Os:  Windows
Architecture:  x86 |  
---+
Changes (by sof):

 * cc: sof (added)

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:18
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2008-12-02 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
---+
Reporter:  FalconNL|Owner: 
Type:  bug |   Status:  new
Priority:  normal  |Milestone:  6.10.2 
   Component:  libraries/base  |  Version:  6.8.2  
Severity:  normal  |   Resolution: 
Keywords:  hsetbuffering buffering buffer  |   Difficulty:  Unknown
Testcase:  |   Os:  Windows
Architecture:  x86 |  
---+
Changes (by ryani):

 * cc: ryani (added)

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:16
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2008-12-01 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
---+
Reporter:  FalconNL|Owner: 
Type:  bug |   Status:  new
Priority:  normal  |Milestone:  6.10.2 
   Component:  libraries/base  |  Version:  6.8.2  
Severity:  normal  |   Resolution: 
Keywords:  hsetbuffering buffering buffer  |   Difficulty:  Unknown
Testcase:  |   Os:  Windows
Architecture:  x86 |  
---+
Changes (by simonpj):

  * priority:  high = normal

Comment:

 We'd like to see this solved, but it looks as if it'd be a lot of work for
 a relatively narrow case.  Can anyone else help?  Meanwhile, reducing
 priority.

 Simon  Simon

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:15
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2008-11-11 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
+---
 Reporter:  FalconNL|  Owner: 
 Type:  bug | Status:  new
 Priority:  high|  Milestone:  6.10.2 
Component:  libraries/base  |Version:  6.8.2  
 Severity:  normal  | Resolution: 
 Keywords:  hsetbuffering buffering buffer  | Difficulty:  Unknown
 Testcase:  |   Architecture:  x86
   Os:  Windows |  
+---
Comment (by simonmar):

 First, I completely agree that we should be using the Win32 API directly
 instead of the POSIX compatibility layer.  It's that way for historical
 reasons - I think it was easier to port the IO library to Windows in the
 first place by using the POSIX layer.  As you say, #806 would be helped by
 that, but also the Windows side of #635, and #989.

 The call sequence you posted only applies to the non-threaded RTS.  With
 the threaded RTS, everything is in the IO library.  We still end up
 calling `read()`, but directly from Haskell.

 Incedentally, there ''is'' a way to get a `HANDLE` from a file descriptor:
 `_get_osfhandle(fd)`.  You might want to look at
 `libraries\base\cbits\inputReady.c` for some serious console hackery.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:13
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2008-11-11 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
+---
 Reporter:  FalconNL|  Owner: 
 Type:  bug | Status:  new
 Priority:  high|  Milestone:  6.10.2 
Component:  libraries/base  |Version:  6.8.2  
 Severity:  normal  | Resolution: 
 Keywords:  hsetbuffering buffering buffer  | Difficulty:  Unknown
 Testcase:  |   Architecture:  x86
   Os:  Windows |  
+---
Comment (by Deewiant):

 Heh, I just noticed that `_get_osfhandle` is used about 30 lines down from
 the code I was looking at last time. Thanks for the heads up. Using it
 this might be fixable with a lot less work by just changing the `read`
 call in `IOWorkerProc` to a `ReadFile`.

 The threaded RTS seems to end up in `__hscore_PrelHandle_read` in
 `libraries/base/include/HsBase.h` which is again just a `read` call and
 might be convertable to `ReadFile` without too much trouble.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:14
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

2008-11-10 Thread GHC
#2189: hSetBuffering stdin NoBuffering doesn't work on Windows
+---
 Reporter:  FalconNL|  Owner: 
 Type:  bug | Status:  new
 Priority:  high|  Milestone:  6.10.2 
Component:  libraries/base  |Version:  6.8.2  
 Severity:  normal  | Resolution: 
 Keywords:  hsetbuffering buffering buffer  | Difficulty:  Unknown
 Testcase:  |   Architecture:  x86
   Os:  Windows |  
+---
Changes (by Deewiant):

 * cc: Deewiant (added)
  * summary:  hSetBuffer stdin NoBuffering doesn't seem to work in ghc
  6.8.2 on Windows XP = hSetBuffering stdin
  NoBuffering doesn't work on Windows

Comment:

 Unfortunately conio doesn't mix with ordinary IO, as I demonstrated in a
 response to that thread on glasgow-haskell-users.

 As for the original problem, I think this'd take some work to solve: GHC
 would have to convert to the Win32 API for all of its IO on Windows.
 (That'd also help with #806.)

 What currently happens is the following call chain, starting from
 `hGetChar` (a bit of documentation for any would-be fixers):
 {{{
 System.IO.hGetChar stdin

 -- meanings of numbers: stdin FD, not a socket, offset 0, length 1
 GHC.Handle.readRawBuffer hGetChar 0 0 buffer 0 1

 GHC.Handle.asyncReadRawBuffer 0 0 buffer 0 1

 GHC.Conc.asyncReadBA 0 0 1 0 buffer

 -- offset got applied
 GHC.Conc.asyncRead 0 0 1 buffer

 -- asyncReadzh_fast in rts/PrimOps.cmm
 asyncRead# 0 0 1 buffer

 -- in rts/win32/AsyncIO.c
 -- the new 0 signifies that this is a read and not a write
 addIORequest(0, 0, 0, 1, buffer)
 }}}
 From there it ends up into the asynchronous IO work queue, whence it
 eventually gets picked up by `IOWorkerProc` (in rts/win32/IOManager.c). It
 notices that the `workKind` is `WORKER_READ` but not `WORKER_FOR_SOCKET`,
 so it does a plain `read()` call.

 In the current situation that's basically fine, since the `hSetBuffering`
 never did anything and we're still in line buffered mode. In unbuffered
 mode, that'd be a problem, as the comment from System.Posix.Internals
 (which judah posted above) asserts: enter needs to be pressed twice. The
 fact that it gives '\r' instead of '\n' isn't such a big problem since it
 can be easily modified.

 I'm attaching a C program which shows how the problem is avoided by using
 the Win32 API directly (in this case, `ReadFile` is fine) instead of the
 POSIX `read`: the latter requires two presses of enter, the former only
 one.

 Since there seems to be no way of getting a Win32 `HANDLE` object from a C
 `FILE*` let alone a POSIX file descriptor, I believe that the only
 reasonable way of getting this and #806 to work reliably is to convert the
 whole IO subsystem to use the Windows API directly—starting from changing
 `GHC.IOBase.Handle__.haFD` from an `FD` to a `HANDLE` on Windows.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2189#comment:12
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs