In modern systems, we rarely see the old DB9 connectors. Instead, we use USB-to-TTL adapters (like FTDI chips). Regardless of the physical layer, the software logic remains the same.
buf[pos] = '\0'; tcsetattr(fd, TCSANOW, &old); return pos; serial port c example
These are critical. VMIN sets the minimum number of bytes to wait for; VTIME sets the inter-character timer in deciseconds. In modern systems, we rarely see the old DB9 connectors