如何在特定的/dev/ttyX(或/dev/pts/X)设备上启动bash ?

时间:2021-05-20 21:02:17

-- Real device --

——真实的设备

Let's say I an UART cable on /dev/ttyACM0 (and there is another computer connected to the other end of the cable), how can I start a bash session on that /dev/ttyACM0 device? So my other computer would be able to execute bash commands?

假设我在/dev/ttyACM0上有一个UART电缆(还有另一台计算机连接到电缆的另一端),我如何在那个/dev/ttyACM0设备上启动bash会话?那么我的另一台电脑能执行bash命令吗?

-- Pseudo terminal --

——伪终端

Another example, let's say I opened cutecom or minicom in device /dev/ptmx, it will create a corresponding /dev/pts/X device. How can I start a bash session to run on the created /dev/pts/X?

另一个例子,假设我在设备/dev/ptmx中打开了cutecom或minicom,它将创建一个相应的/dev/pts/X设备。如何在创建的/dev/pts/X上启动bash会话?

If I understand correct, it doesn't matter to bash (or getty) if it is running on a real or pseudo terminal. So I think that GUI terminals (like xterm) read /dev/ptmx and start a bash on the corresponding /dev/pts/X, if this is true, then I should be able to do the same, how can I accomplish that? Or is my understanding of it wrong?

如果我理解正确,那么在一个真实的或伪终端上运行时抨击(或盖蒂)并不重要。因此,我认为GUI终端(比如xterm)读取/dev/ptmx并对相应的/dev/pts/X启动一个bash,如果这是真的,那么我应该能够做同样的事情,我如何才能做到呢?还是我的理解错了?

1 个解决方案

#1


3  

fork() a child process. Open the serial device or pseudotty and dup2() it to fd's 0, 1 and 2. execv() your preferred shell.

fork()子进程。打开串行设备或伪tty和dup2()到fd的0,1和2。execv()你喜欢的外壳。

#1


3  

fork() a child process. Open the serial device or pseudotty and dup2() it to fd's 0, 1 and 2. execv() your preferred shell.

fork()子进程。打开串行设备或伪tty和dup2()到fd的0,1和2。execv()你喜欢的外壳。