Linux is only free if your time has no value.
The thermostat that we developed in the last chapter isn’t very practical because the operating parameters, setpoint, limit, and deadband are hardcoded into the program. Any practical thermostat would make these parameters user adjustable. In this case, we might invent a simple command protocol to change the parameters through the console.
How might we implement such a process? Back in the old DOS days, we might have used the function kbhit() to poll the keyboard for activity. But Linux is a multitasking system. Polling is tacky. What we need is an independent thread of execution that waits for a line of text on the console, parses the line, and acts on it.