Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [pty]

Pseudoterminals (also spelled “pseudotty” or “PTY”) are pseudo-devices used with ttys whose emulators run in userspace. Use the [tty] tag for broad (text terminal)-related questions, and the [console] tag for terminal devices pertaining to the system console.

Filter by
Sorted by
Tagged with
0 votes
1 answer
42 views

xterm seems to change its "home" key behaviour for emacs

In xterm, when I press the HOME key on my keyboard, it normally sends ^[[H but when I open emacs -nw, it changes to ^[OH; those are home and khome respectively. I figured out while trying to build my ...
Alex028502's user avatar
0 votes
2 answers
60 views

How can I connect a bash process to a tty _without_ using getty

I would have two serial usb devices connected to each other, /dev/ttyUSB1 and /dev/ttyUSB2. I would like to run /bin/bash connected to one end, so that I can attach to the other end using picocom and ...
Alex028502's user avatar
1 vote
1 answer
50 views

job control doesn't work when I create my own pty pair with socat

I am experimenting with understanding terminal emulators by looking at the different pieces of the puzzle. I am trying to start a pty pair and shell process with socat, and then connect to it with ...
Alex028502's user avatar
0 votes
1 answer
38 views

how to get file descriptors of PTY inside of a child?

https://man7.org/linux/man-pages/man7/pty.7.html in the "UNIX 98 pseudoterminals" it is said that ptsname can be used (and then open), but this function accepts file descriptor. i tried to ...
Michael Quad's user avatar
0 votes
1 answer
48 views

Pseudo-terminals control each other, how to get the return display

The problem is: my pseudo-terminal is /dev/pts/0, the target pseudo-terminal is /dev/pts/4, and I'm trying to get the target pseudo-terminal to print text using the echo text > /dev/pts/4 command. ...
xnl2d's user avatar
  • 17
2 votes
0 answers
423 views

How to suppress "Failed to set controlling terminal" warning in GDB when setting program to run on another terminal?

I'm using GDB to debug a program, and I want to direct its output to a different terminal than the one where GDB is running. Here's what I've been doing: Open a second terminal, check its device name ...
Sebastian Carlos's user avatar
0 votes
0 answers
103 views

How to reown a process?

when i run this script with a shortcut(sxhkd): #!/bin/sh MUSIC_DIR="$HOME/music" songs=$(ls "$MUSIC_DIR") filename=$( echo -e "random\n$songs" | dmenu -l 30 -i -p &...
white-hat-er's user avatar
0 votes
1 answer
145 views

how can I make socat simulate unplugging a serial device

I have this test program import sys for line in sys.stdin: print(line.strip()) print("DONE") if I get it to print out lines from a real device (an FTDI) python3 demo.py < /dev/...
Alex028502's user avatar
0 votes
1 answer
87 views

Can I set up a serial terminal (RS-232) without a pty?

I have two computers that both have a RS-232 port on /dev/ttyS0 connect together with a null modem. I am trying to understand bit by bit how an external terminal worked in the old days, and how that ...
Alex028502's user avatar
1 vote
1 answer
1k views

trying to make my own shell handle ctrl+c properly

I am trying to understand how shells are set up so that the programs they are running receive the SIGINT when you press ctrl C but the shell doesn't, because when you are running bash, and run another ...
Alex028502's user avatar
0 votes
1 answer
224 views

How to determine the graphical tty in loginctl

Loginctl lists a lot of sessions, and I want programmatically to know which one is a graphical session (e.g. GNOME desktop). In the example below, I have a GNome desktop session open, an ssh ...
Eric Stdlib's user avatar
0 votes
1 answer
265 views

Pseudo terminal for comms between two processes

I am writing an executable that uses a 3rd party C library (libmodbus if it matters) to communicate via serial device (in my case, /dev/ttyUSB0 or similar to talk RS-485 via an FTDI chipset based USB-...
Paul Grinberg's user avatar
1 vote
2 answers
347 views

/proc/self/fd/2 can not be accessed under `sudo -u other_user`

I often use tee /proc/self/fd/2 to show something both to stdout and stderr, capture stdout, while still keep all output to stderr. E.g., I have a do.sh: STD_OUT_STR=$(CMD ARGS ... 2>&1 | tee /...
osexp2000's user avatar
  • 532
1 vote
1 answer
163 views

How to pipe terminal interaction with running process over network?

How can I run a program that expects to be executing in a terminal in such a way that it's STDIO can be arbitrarily connected-to remotely? Specifically, I want to be able to launch gdb on one host and ...
Billy's user avatar
  • 111
1 vote
1 answer
732 views

how to remove the buffer when simulating a serial device with socat

I am creating a fake serial device like this: socat -d -d pty,raw,echo=0 pty,raw,echo=0 This creates devices with new numbers each time. Let's call them /dev/pty/6 and /dev/pty/7 To simulate a ...
Alex028502's user avatar
2 votes
1 answer
225 views

zsh zpty does not work on macOS, does work on Linux?

zsh module zsh/zpty seems to work perfectly well on my Linux virtual machine running on Apple M1 macOS machine. But the same does not work on macOS (even on the same host machine). I have tried this ...
codepoet's user avatar
  • 596
3 votes
1 answer
9k views

"sudo: unable to allocate pty: No such device" in chrooted Linux

Added: After reading suggested as duplicate Which of proc, sys etc. should be bind-mounted (or not) when chrooting into a "replacement" distribution? : How I know: it is customary to invoke ...
Alex Martian's user avatar
  • 1,055
5 votes
1 answer
2k views

How does the use_pty sudoers option prevent a persistence attack?

As a rule in the Debian 10 hardening guide, and various other audit guides of the Center for Internet Security (CIS), setting the use_pty sudoers option is recommended for the following rationale: ...
Flo's user avatar
  • 51
3 votes
1 answer
188 views

SSH under pty still promts stdin from terminal

I am currently learning about the pseudo-terminal functionalities in C. I am able to create the master, slave end of the pty, after fork, I have set the stdin, stdout, stderr to fd slave , after exec ...
chellathurai's user avatar
0 votes
1 answer
935 views

How to get color in terminal but no color in output file [duplicate]

To show output in both terminal and to a file, tee can be used like below ls --color=auto | tee opfile But now, there is no color in the terminal. If I force colors, opfile also has colors which ...
balki's user avatar
  • 4,407
1 vote
1 answer
2k views

Why dmesg output displayed on /dev/tty1

This is still related to my yesterday thread, so there's alert or maybe it's just log that displayed on my terminal on /dev/tty1. Ofcourse it's annoying because it's displayed in my bash prompt, so ...
Muhammad Ikhwan Perwira's user avatar
2 votes
1 answer
142 views

Do programs that create pseudoterminals emulate terminals?

The way I understand it, applications that create a pty (a master/slave pair) can be separated into 2 categories: terminal emulators (xterm, urxvt, ...), which supposedly produce graphical output the ...
x-yuri's user avatar
  • 3,383
0 votes
1 answer
155 views

Verbose logging: howto save disk?

Situation I'm running a program on Linux, which produces a lot of verbose logs to stdout. The program itself is put into background by using systemd.service facilities. Until now, I have configured ...
Daniel's user avatar
  • 339
1 vote
1 answer
1k views

How do I display a bash prompt when using SSH without a pseudo-terminal?

When the connection is slow, I connect to remote computers using SSH without allocating a pseudo-terminal (e.g. ssh -T [email protected] or ssh [email protected] bash). Although I am able to use the ...
Flux's user avatar
  • 2,958
3 votes
1 answer
988 views

Perplexity about TTY and PTY

I'm trying to understand this topic but, apparently, for my brain it is too hard. Terminal device entries normally reside in two directories: /dev and /dev/pts. The /dev directory contains entries ...
vittorioc98's user avatar
0 votes
0 answers
163 views

How does terminal in Linux actually work? [duplicate]

I'm using Linux console for years, but currently started thinking of how it actually works. Typing a command as a string and pressing Enter returns its output in the same terminal window. Opening a ...
Some Name's user avatar
  • 255
3 votes
1 answer
5k views

What is Virtual Serial Port in QEMU?

Ubuntu 20.04 both on host and guest. I'm new to QEMU and trying to set up guest-host communication via serial port. The QEMU documentation says that -serial dev option: Redirect the virtual serial ...
Some Name's user avatar
  • 255
-1 votes
2 answers
791 views

Why does the input cursor always go from the top to the bottom in a terminal emulator?

I noticed that the terminal cursor starts at the top of the terminal and slowly moves down as more commands are executed, until ultimately settling on the bottom regardless of the number of commands. ...
Stephen Wood's user avatar
1 vote
3 answers
347 views

What "bad" things may happen (and why) if a Terminal Emulator and the Shell running in it are using different TERM types?

For example, in PuTTY's configuration I set terminal type to xterm-256color but after SSH login I change it with export TERM=linux in the shell. I know it works quite well for most time. Just want to ...
UNIX.root's user avatar
  • 184
1 vote
2 answers
458 views

How can I clean up output from expect?

Background: I'm using expect to connect between AMCE.sh and a managed network switch. I can connect to the switch via SSH, log in and issue commands but because of the way the switch manages SSL ...
RobbG's user avatar
  • 175
-1 votes
1 answer
447 views

Why is Linux giving a pts number for real terminal console? (which is not an emulated terminal like ssh or xterm)

I read that pts is a pseudo-terminal (that we get through ssh or xterm) and tty is the native terminal. I didn't connect to my PC through ssh or xterm, but I am still getting pts/0 and pts/1 when I ...
Gaurav Purswani's user avatar
1 vote
0 answers
190 views

Interpret bash escape sequences and other characters using ncurses

I want to design a terminal multiplexer like tmux, but not that complex, something minimal, that works remote, using ncurses. On the server side, the workflow is as follows: The server process ...
rel0adedd's user avatar
0 votes
1 answer
120 views

Are there tools that I can use to obtain a snapshot of terminal or pty state? [duplicate]

Please stop marking this question as a duplicate, it's not a duplicate. Thanks. Consider the sequence of a, followed by \x1b[D ("cursor back"), followed by b. This would produce an output of ...
Steven Lu's user avatar
  • 2,292
3 votes
1 answer
2k views

Shell Upgrade: script typescript command using bash

Can anyone explain what this means: SHELL=/bin/bash script -q /dev/null It is used to upgrade a shell in a CTF in HTB: SHELL=/bin/bash script -q /dev/null Ctrl-Z stty raw -echo fg reset xterm ...
Matthias Altmann's user avatar
0 votes
1 answer
196 views

script -c '...' does NOT print colors

edit: I was in EternalTerminal session, and that was the source of the difference. In a regular ssh, it works. I need to get commands in a pipe to believe they are in a PTY and emit colorized output. ...
Victor Sergienko's user avatar
0 votes
0 answers
2k views

Link character device to pty with socat

I have a "regular character device" - not sure of the proper naming - that doesn't support ioctl on an embedded device (/dev/appvcom). I need to connect to it with an application that uses some ioctl ...
toster-cx's user avatar
  • 101
0 votes
2 answers
317 views

How to replace program running in graphical terminal with another program?

Lets say I have top or some ncurses program running in a graphical terminal, and from outside this terminal I'd like to execute a command, that would replace top with another program of my choosing. ...
Alex Stragies's user avatar
0 votes
1 answer
812 views

Alternative to "openvt", but for pseudo terminal (pts). Exists?

Alternative to "openvt"...but for pseudo terminal(pts)... Exists? Openvrt operate only tty...but not pts. (Example: lauch comand in specific pts and with user of shell pts destination) Command <...
vincenzogianfelice's user avatar
1 vote
1 answer
1k views

How bash sets tty attributes before and after running a command?

Open xterm, run tty and see pseudo terminal slave file (let's say it is /dev/pts/0). Then open another xterm and run $ stty -F /dev/pts/0 speed 38400 baud; line = 0; lnext = <undef>; discard = &...
Igor Liferenko's user avatar
3 votes
1 answer
3k views

What is the difference between IXON and IXOFF tty attributes?

To be specific, let's speak in pseudo-terminal terms. Suppose we have file descriptors master and slave for a pseudo-terminal pair (suppose it is a controlling tty). Disabling IXON on master (or slave,...
Igor Liferenko's user avatar
0 votes
1 answer
600 views

Detect pty buffer capacity

I am using the tty subsystem of Linux to emulate serial ports. The emulated serial ports are used by an application that expects a physical serial port. In my case, the application is running under ...
millinon's user avatar
  • 343
0 votes
0 answers
577 views

Why does changing my home directory in WSL break my PATH but only in the second window in tmux?

A bit ago, I found it necessary to set my home directory to my One Drive in WSL. Thanks to this post I was even able to get my permissions working correctly within WSL (Ubuntu 16.04 LTS). However, ...
leeand00's user avatar
  • 4,625
1 vote
0 answers
914 views

Restricted shell within docker container

Some context for my question: I am working on a pty NodeJS server running in docker where I want to provide users connecting to the shell an isolated environment where they can play around with ...
Joakim Hansson's user avatar
8 votes
1 answer
1k views

Why blocking read() on a pty returns when process on the other end dies?

When slave side of pty is not opened, strace on the process, which does read(master_fd, &byte, 1);, shows this: read(3, So, when nobody is connected to the slave side of pty, read() waits for ...
Igor Liferenko's user avatar
1 vote
1 answer
975 views

How TTY differs from an ordinary file? [duplicate]

I'm trying to understand ssh's -t option: -t Force pseudo-terminal allocation. This can be used to execute arbitrary screen- based programs on a remote machine, which can be ...
Igor Liferenko's user avatar
0 votes
0 answers
38 views

Why does macOS specific terminal shortcuts like Left-arrow + Option work in a remote shell on Ubuntu with a dedicated pty?

Why do macOS specific terminal shortcuts like Left-arrow + Option work in a remote shell on Ubuntu with a dedicated pty? I'm trying to understand why macOS specific terminal shortcuts like Left-arrow ...
Shuzheng's user avatar
  • 4,471
2 votes
1 answer
466 views

PTY master missing read function

How can terminal emulator read from ptm device while it missing read function? There is a PTY driver: https://github.com/torvalds/linux/blob/master/drivers/tty/pty.c. I see pty_write function, but can'...
TwITe's user avatar
  • 151
3 votes
1 answer
1k views

What exactly tty line discipline does with input from pty slave device?

I know that tty line discipline processes special characters (such as ^C, ^? and etc), but it is only about input from pty master device. But what about input from pty slave device? What tty line ...
TwITe's user avatar
  • 151
1 vote
0 answers
105 views

Can terminal parameter changes on the slave side be detected on master?

A process (creator) creates a pseudo-terminal master/slave[/dev/pts/1] pair. Another process (consumer) opens /dev/pts/1 and changes the serial terminal parameters with tcsetattr. Is there a way for ...
TheMeaningfulEngineer's user avatar
1 vote
2 answers
136 views

less: advertise terminfo through pipe

If I do ls | less, ls detects that it isn't connected to a terminal, which is fair enough. Except that less is connected to a terminal. In this setup, ls could produce the coloured and columnised ...
Eric Toombs's user avatar