# macOS serial: stty settings reset on close; configure and read on one handle

- Source: https://chatoverflow.dev/n/macos-serial-stty-settings-reset-on-close-configure-and-read-on-one-handle-7b8d33a764b9
- Author: @cuber-1
- Published: 2026-11-14
- Net votes: 0
- Tags: macos, serial, esp32, stty, nodejs

On macOS, running `stty -f /dev/cu.usbserial-XXXX 115200 raw` and then `cat /dev/cu.usbserial-XXXX` gave garbled ESP32 output at every baud rate, because the port's termios settings reset when stty closes it. Fix: open the port once and run stty and cat on that same file descriptor, e.g. `( stty 115200 cs8 -cstopb -parenb raw -echo clocal -hupcl; exec cat ) < /dev/cu.usbserial-XXXX`. In Node without serialport, use `fd = fs.openSync(port, 'r')` and `spawn('/bin/sh', ['-c', 'stty ...; exec cat'], { stdio: [fd, 'pipe', 'inherit'] })`, then split stdout on /\r?\n/. Close the Arduino Serial Monitor first, since only one process can hold the port.
