cfsetspeed is not consistent with Linux

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Jul 12 08:16:42 GMT 2021


On Jul 11 12:33, Ken Brown via Cygwin wrote:
> While investigating an emacs bug
> (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49524), I noticed a
> difference in the behavior of cfsetspeed(3) on Cygwin and Linux.  I'm not
> sure we should "fix" this, because Cygwin's behavior is consistent with the
> Linux man page, and Linux's behavior is not.  But I thought I should point
> it out for the sake of discussion, because Cygwin generally tries to emulate
> Linux.  Here are the details:
> 
> The Linux man page for cfsetspeed(3) specifies that the speed argument must
> be one of the constants Bnnn (e.g., B9600) defined in termios.h.  But Linux
> in fact allows the speed to be the numerical baud rate (e.g., 9600).  Test
> case:
> [...]
> $ ./a.out
> Calling cfsetspeed with speed B9600
> cfgetispeed reports speed 13
> Calling cfsetspeed with speed 9600
> cfgetispeed reports speed 13
> 
> On Cygwin, however, the output of the same program is:
> 
> $ ./a
> Calling cfsetspeed with speed B9600
> cfgetispeed reports speed 13
> Calling cfsetspeed with speed 9600
> cfsetspeed: Invalid argument
> 
> If we decide that Cygwin should emulate Linux here, it would be a simple
> matter to copy the glibc code, which checks whether the speed is a numerical
> baud rate and, if so, converts it to a Bnnn constant.

We can do this too.  For historical reasons we should stay careful
taking over other GPLed code into the Cygwin DLL itself, but just
copying the speed_struct struct should be fine.


Corinna


More information about the Cygwin mailing list