jputcu / serialport

Cross platform haskell library for using the serial port
Other
43 stars 36 forks source link

Only apply O_NONBLOCK hack on Darwin #22

Closed bgamari closed 10 years ago

bgamari commented 10 years ago

This hack should only be applied when necessary.

jputcu commented 10 years ago

I've ran my test on both Windows 7 and Linux without any problems, but you are correct, it would be cleaner to only apply this workaround for osx. Would be nice if it could be detected from within the code in stead of the cabal and preprocessor define.

bgamari commented 10 years ago

Joris Putcuyps notifications@github.com writes:

I've ran my test on both Windows 7 and Linux without any problems, but you are correct, it would be cleaner to only apply this workaround for osx. Would be nicer if it could be detected from within the code in stead of the cabal and preprocessor define.

I think it's pretty widely accepted that the most reliable way to implement checks like this is at compile time. The only potential issue is cross compilation but Cabal's os() condition is defined to test against the operating system of the target so even this shouldn't pose a problem. I believe that applications like this is why os was introduced in the first place..