CFGETISPEED(3P)
π«Ά PROLOG
okay bestie, real talk before we even start π this page is part of the POSIX Programmer's Manual (that's the manual name, keep it in your notes). But β and this is the important part β the Linux implementation of this interface may differ, so go check the corresponding Linux manual page for the deets on Linux behavior. Or, plot twist, the interface might not even be implemented on Linux at all. π so don't come for me if it's not there.
β¨ NAME β¨
cfgetispeed β get input baud rate π
πΈ SYNOPSIS πΈ
#include <termios.h>
speed_t cfgetispeed(const struct termios *termios_p);
π DESCRIPTION π
so cfgetispeed() shall extract the input baud rate from the termios structure that the termios_p argument points at. that's it. that's the job. π
and the way this function is giving exactly the value sitting in the termios data structure β no interpretation, no vibes-based reinterpreting, nothing. raw value, periodt.
β RETURN VALUE β
upon successful completion (slay), cfgetispeed() shall return a value of type speed_t representing the input baud rate. π
π¦ ERRORS π¦
no errors are defined. not a single one. she simply does not miss. β¨
heads up though: the following sections are informative. π
π EXAMPLES π
None. (bestie there is literally nothing here, I'm as disappointed as you are π)
π APPLICATION USAGE π
None. (again!! nothing!! the void!! π)
π RATIONALE π
okay this is the juicy part, grab a snack π
the term "baud" is used here historically, but ngl it's not technically correct. what this actually means is "bits per second", which may not be the same thing as baud. but the term stuck around because of historical usage and understanding. iykyk. π
so the functions cfgetospeed(), cfgetispeed(), cfsetospeed(), and cfsetispeed() do not take arguments as numbers β they take them as symbolic names. and there are two reasons for that:
- Historically, numbers weren't used because of the way the rate was stored in the data structure. this is retained even though a function is now used.
- More importantly, only a limited set of possible rates is at all portable, and this constrains the application to that set.
and there is nothing to prevent an implementation from accepting as an extension a number (like 126, for example), and since the encoding of the Bxxx symbols is not specified, this can be done to avoid introducing ambiguity. so it's giving "we left the door open on purpose." πͺβ¨
now, setting the input baud rate to zero was a mechanism to allow for split baud rates. clarifications in this volume of POSIX.1β2017 have made it possible to determine whether split rates are supported and to support them without having to treat zero as a special case. but since this functionality is also confusing, it has been declared obsolescent. β οΈ
and listen carefully: the 0 argument referred to is the literal constant 0, not the symbolic constant B0. this volume of POSIX.1β2017 does not preclude B0 from being defined as the value 0; in fact, implementations would likely benefit from the two being equivalent. this volume of POSIX.1β2017 does not fully specify whether the previous cfsetispeed() value is retained after a tcgetattr() as the actual value or as zero. therefore, conforming applications should always set both the input speed and output speed when setting either. like, both. every time. no shortcuts. π«Ά
in historical implementations, the baud rate information is traditionally kept in c_cflag. applications should be written to presume that this might be the case (and thus not blindly copy c_cflag), but not to rely on it in case it's in some other field of the structure. setting the c_cflag field absolutely after setting a baud rate is a non-portable action because of this. in general, the unused parts of the flag fields might be used by the implementation and should not be blindly copied from the descriptions of one terminal device to another. π
π₯ FUTURE DIRECTIONS π₯
None.
π SEE ALSO π
cfgetospeed()cfsetispeed()cfsetospeed()tcgetattr()
and also the Base Definitions volume of POSIX.1β2017, Chapter 11, General Terminal Interface, <termios.h> β go read it, it's iconic, no cap πβ¨
πΈ COPYRIGHT πΈ
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie!! π«Ά this little manual page is brought to you by IEEE/The Open Group, dated 2017 β shoutout to the CFGETISPEED(3P) girlies, she ate and left no crumbs π
β¨ bye!! ππ¦
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms