December 6, 2020
This is a good post describing the issue and the nice solution that ylluminarious came up with. The patches linked in the post no longer apply cleanly to Emacs 27.1 so I put up a gist of an updated, combined patch.
You can follow these steps to apply the patch and build Emacs 27.1 from Emacs Mac port source.
git clone https://bitbucket.org/mituharu/emacs-mac cd emacs-mac git checkout emacs-27.1-mac-8.1 autoreconf -i wget https://gist.github.com/genegoykhman/6effe7fa25696c49d0519af877f5fb42/raw -O multi-tty.patch git apply multi-tty.patch ./configure --without-makeinfo --with-modules --enable-mac-app --prefix=/Applications/Emacs.app/Contents/Resources make install