www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Problem interacting with the console

reply Jacob Carlborg <doob me.com> writes:
I'm trying to port a C application to D. The problem I have is 
interacting with the console. I'm using the POSIX "read" function, the 
problem is that in the D version the "read" function seems to never 
return. The C version works fine and prints "**********" after I press a 
key. I've created a small test case for the problem below:

D code: http://pastebin.com/SsYZcjMG
C code: http://pastebin.com/QyprKD17

Is suspect that it's something in the "initterm" function that isn't 
working properly. Any ideas?

I'm using DMD 2.058 on Mac OS X.

-- 
/Jacob Carlborg
Mar 29 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-03-29 21:51, Jacob Carlborg wrote:
 I'm trying to port a C application to D. The problem I have is
 interacting with the console. I'm using the POSIX "read" function, the
 problem is that in the D version the "read" function seems to never
 return. The C version works fine and prints "**********" after I press a
 key. I've created a small test case for the problem below:

 D code: http://pastebin.com/SsYZcjMG
 C code: http://pastebin.com/QyprKD17

 Is suspect that it's something in the "initterm" function that isn't
 working properly. Any ideas?

 I'm using DMD 2.058 on Mac OS X.

If anyone else is interested, I finally find the problem. Some types used by the termios struct was incorrectly declared resulting in the wrong size on 64bit. I've created a pull request for this in druntime: https://github.com/D-Programming-Language/druntime/pull/189 -- /Jacob Carlborg
Mar 31 2012