Issue #5 new

read doesn't block on Mac OS X

Dave Brondsema
created an issue

When I call getch() on Mac OS X, the first call is blocking and waits for a keypress. But subsequent calls immediately returns an empty string rather than blocking for a keypress. As best I can tell, the termios.tcsetattr call to restore the old settings (vmin and vtime) does not take affect. Calling tcgetattr shows that vmin & vtime have been restored, but apparently something is causing them not to work. I've tried changing that tcsetattr method to use the TCSANOW or TCSAFLUSH flags, but it doesn't help.

The root problem seems like it might be within OS X or an OS X library, but a workaround in this "pager" library would be extremely helpful.

Comments (2)

  1. Dave Brondsema reporter

    Unfortunately those recipes don't work. They're very old and the carbon imports don't work any more. Carbon was deprecated before OS X.

    I looked at PyObjC and Cocoa/Quartz libraries. They are probably the best way to get keypresses directly from OSX, but are quite complicated and seem to require a lot of setup in your application, including running an event loop. That doesn't seem like a good fit for the 'pager' package.

    In theory OS X terminals are POSIX compatible, it just seems to be buggy here :(

  2. Log in to comment