bash
works with STDIN, STDOUT and STDERR. When xterm
is opened,
it allocates the pseudo tty. Then xterm forks child process and STDIN, STDOUT, STDERR are tied to slave_fd
via dup2
and exec
is called with bash
. This is good.
But how to make bash
work with TTY directly? How to make bash
execute open("/dev/ttyS0", O_RDWR)
? So that I could attach a device to /dev/ttyS0
and execute commands in bash
from the device.
open("/dev/ttyS0", O_RDWR)
and sometimes I want to interact with the program viaxterm
, without changing the program itself - is this possible? – Igor Liferenko Aug 21 '19 at 02:21exec 7<>/dev/ttyS0; stty <&7 [your stty settings]; cmd1 >&7; cmd2 <&7; cmd3 <&7 >&7 2>&1
. Setting the right modes & speed and using serial devices from the shell and parsing responses is tricky, though. – Aug 21 '19 at 04:07open
on the TTY. I asked this question because I was curious about general mechanisms how programs connect to TTY. As it turned out, as a rule an intermediate program is used for that. – Igor Liferenko Aug 21 '19 at 07:33