--- src/readline_curses.cc.orig 2025-02-13 03:25:07.000000000 +0800 +++ src/readline_curses.cc 2025-04-05 17:27:56.000000000 +0800 @@ -57,6 +57,10 @@ #include #include +#ifdef __APPLE__ +#include +#endif + #include "base/ansi_scrubber.hh" #include "base/auto_mem.hh" #include "base/fs_util.hh" @@ -846,6 +850,7 @@ log_perror(grantpt(this->rc_pty[RCF_MASTER])); log_perror(unlockpt(this->rc_pty[RCF_MASTER])); char slave_path_str[PATH_MAX]; +#if !defined(__APPLE__) || (MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) if (ptsname_r( this->rc_pty[RCF_MASTER], slave_path_str, sizeof(slave_path_str)) == -1) @@ -853,6 +858,15 @@ perror("ptsname_r"); throw error(errno); } +#else + char *slave_path_cstr = ptsname(this->rc_pty[RCF_MASTER]); + if (slave_path_cstr == nullptr) { + perror("ptsname"); + throw error(errno); + } + strncpy(slave_path_str, slave_path_cstr, sizeof(slave_path_str) - 1); + slave_path_str[sizeof(slave_path_str) - 1] = '\0'; +#endif auto slave_path = std::filesystem::path(slave_path_str); std::error_code ec;