How does Terminal.app detect a change to the terminal parameters?

Solution 1:

Terminal polls the tty device state using tcgetattr(3) x-man-page://3/tcgetattr and checks that the c_lflag ICANON flag is set and the ECHO flag is not.

It polls after receiving output from the remote program, or when the user enters text using an inline input method that may need to be blocked from displaying user input as “marked” text.

Solution 2:

Since Terminal.app is closed source, no one can do more than guess exactly what it does (polling or some notification feature that Apple's provided). In any case, it does have complete control over the data moving between the master/slave pseudoterminals, and could poll that using POSIX termios calls such as tcgetattr to see what the current terminal modes are.