无法在Mac OS High Sierra下打开pty [英] Cannot open pty under Mac OS High Sierra

查看:68
本文介绍了无法在Mac OS High Sierra下打开pty的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题的实质是用户程序如何在Mac OS High Sierra上打开pty(例如/dev/ptyp0)?"设备名称的标准open()似乎不起作用,即使其保护为crw-rw-rw-.

The essence of my question is "How can a user program open a pty (e.g., /dev/ptyp0) on Mac OS High Sierra?" A standard open() of the device name does not seem to work, even though its protections are crw-rw-rw-.

上下文正在Mac OS下运行Emacs.在High Sierra之前,我命令Emacs在其中创建一个子进程的Shell窗口时,Emacs分配了一个与子进程进行通信的pty.升级到High Sierra后,Emacs无法再分配pty,而是使用管道与子流程进行通信.这使得子进程的行为不像终端窗口中的外壳程序,这给用户带来了较差的体验.

The context is running Emacs under Mac OS. Before High Sierra, when I ordered Emacs to create a shell window within which is a subprocess, Emacs allocated a pty with which to communicate with the subprocess. After upgrading to High Sierra, Emacs can no longer allocate the pty, and uses pipes to communicate with the subprocess. This makes the subprocess act less like a shell-in-a-terminal-window, which is a poorer user experience.

跟踪Emacs的操作表明,Emacs正在按顺序尝试打开系统上定义的每个pty,并每次收到errno 35.

Tracing Emacs' operations shows that Emacs is trying in sequence to open each of the ptys defined on the system, and receiving errno 35 each time.

我在网上找到了一个项目,该项目表明人们在Mac OS High Sierra上打开pty的方式与以前的Mac OS版本不同,但是没有提供任何细节.

I have located one item online that suggests that how one opens pty's on Mac OS High Sierra is different from previous versions of Mac OS, but it gave no details.

推荐答案

答案的实质是,在类Unix系统上至少使用两种机制来分配pty.High Sierra使用与以前的Mac OS版本不同的机制,该机制显然涉及设备/dev/ptmx,因此,如果您的程序未使用正确的机制,则它将失败.在Emacs的情况下,如果无法分配pty,则将退回到使用管道与子流程进行通信,然后该子流程就不会拥有tty",并且您不能在其上使用tty函数.

The essence of the answer is that there are at least two mechanisms used on Unix-like systems to allocate ptys. High Sierra uses a different mechanism than previous Mac OS versions, one involving the device /dev/ptmx apparently, and so if your program does not use the correct mechanism, it will fail. In Emacs' case, if it fails to allocate a pty, it falls back to using pipes to communicate with a subprocess, which subprocess then does not "have a tty" and you cannot use tty functions on it.

关于Emacs,我使用的是22.1.1版本,该版本配置为使用以前的pty机制(尝试依次打开每个/dev/ptyXX).使用版本26.1可以解决此问题.您可以从 https://emacsformacosx.com

In regard to Emacs, I was using version 22.1.1, which was configured to use the previous pty mechanism (attempting to open each /dev/ptyXX in sequence). The problem is fixed by using version 26.1. You can download version 26.1 of Emacs built as a Mac application from https://emacsformacosx.com

这篇关于无法在Mac OS High Sierra下打开pty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆