Questions tagged [pty]

A pty is a pseudo-terminal - it's a software implementation that appears to the attached program like a terminal, but instead of communicating directly with a "real" terminal, it transfers the input and output to another program.

362 questions
270
votes
8 answers

Confused about Docker -t option to Allocate a pseudo-TTY

What exactly does this option do? I've been reading a lot on TTY and I'm still confused. I played around without having the -t and just -i and it seems like programs that expect user input throw an error without the -t. Why is it important for…
user1099123
  • 4,339
  • 4
  • 22
  • 31
83
votes
21 answers

How to fix request failed on channel 0

When I want to connect to my server like this ssh -a username@my-server.de -p 22 it gives me two error messages: PTY allocation request failed on channel 0 shell request failed on channel 0 When I use the parameter -T the first error message goes…
user1895268
  • 1,089
  • 1
  • 8
  • 22
38
votes
4 answers

Can you fool isatty AND log stdout and stderr separately?

Problem So you want to log the stdout and stderr (separately) of a process or subprocess, without the output being different from what you'd see in the terminal if you weren't logging anything. Seems pretty simple no? Well unfortunately, it appears…
J.J
  • 2,971
  • 1
  • 24
  • 33
31
votes
5 answers

Final output on slave pty is lost if it was not closed in parent. Why?

I wrote and maintain a program rlwrap that uses a pseudo-terminal to communicate with a child process. Pseudo-terminals (ptys) are found in all Unix(-like) systems, but they behave slightly differently on different platforms. Case in point: In…
Hans Lub
  • 5,054
  • 1
  • 18
  • 39
24
votes
2 answers

Detecting when a child process is waiting for input

I'm writing a Python program for running user-uploaded arbitrary (and thus, at the worst case, unsafe, erroneous and crashing) code on a Linux server. The security questions aside, my objective is to determine, if the code (that might be in any…
miikkas
  • 748
  • 1
  • 6
  • 25
23
votes
1 answer

Piping data to Linux program which expects a TTY (terminal)

I have a program in Linux which refuses to run if its stdin/stdout is not a TTY (terminal device). Is there an easy-to-use tool which will create a PTY, start the program with the newly created TTY, and copy all data over stdin/stdout? The use case…
pts
  • 64,123
  • 15
  • 92
  • 159
21
votes
3 answers

How do I read the output of a child process without blocking in Rust?

I'm making a small ncurses application in Rust that needs to communicate with a child process. I already have a prototype written in Common Lisp. I'm trying to rewrite it because CL uses a huge amount of memory for such a small tool. I'm having some…
jkiiski
  • 7,539
  • 1
  • 26
  • 40
20
votes
2 answers

Why does running a background task over ssh fail if a pseudo-tty is allocated?

I've recently run into some slightly odd behaviour when running commands over ssh. I would be interested to hear any explanations for the behaviour below. Running ssh localhost 'touch foobar &' creates a file called foobar as expected: [bob@server…
20
votes
3 answers

Run command and get its stdout, stderr separately in near real time like in a terminal

I am trying to find a way in Python to run other programs in such a way that: The stdout and stderr of the program being run can be logged separately. The stdout and stderr of the program being run can be viewed in near-real time, such that if the…
J.J
  • 2,971
  • 1
  • 24
  • 33
16
votes
1 answer

difference between pty and a pipe

I have been reading about ptys from this page's example: http://www.rkoucha.fr/tech_corner/pty_pdip.html. I have two questions: What is the difference, or the most important difference, between using a pty and using a pipe? From what I have read,…
kprincipe
  • 311
  • 1
  • 9
14
votes
3 answers

Python: when to use pty.fork() versus os.fork()

I'm uncertain whether to use pty.fork() or os.fork() when spawning external background processes from my app. (Such as chess engines) I want the spawned processes to die if the parent is killed, as with spawning apps in a terminal. What are the ups…
Thomas Ahle
  • 28,005
  • 19
  • 77
  • 105
14
votes
3 answers

Ruby on Linux PTY goes away without EOF, raises Errno::EIO

I'm writing some code which takes a file, passes that file to one of several binaries for processing, and monitors the conversion process for errors. I've written and tested the following routine on OSX but linux fails for reasons about which I'm…
voxobscuro
  • 1,948
  • 1
  • 20
  • 38
13
votes
3 answers

How to use pseudo-terminals in Linux with C?

I'm trying to figure out how to use pseudo-terminal's in linux, essentially I want to create a telnetd clone, something I mentioned in an earlier question. I understand the concept of master and slave terminal, and I have a basic grasp on how to use…
Irresponsible Newb
  • 543
  • 2
  • 6
  • 14
13
votes
2 answers

How can I detect when someone opens the slave side of a pty (pseudo-terminal) in Linux?

Having more than one process read from a serial device (/dev/ttyXX) makes it so that both processes can't get all of the data -- the data will be split between them in some way. I'd like to write a program that reads from a serial device, creates…
Nate Sanders
  • 133
  • 1
  • 4
13
votes
2 answers

node-gyp error while doing npm install

I am doing npm install from a project and I am getting this wierd error in node-gyp. > pty.js@0.2.3 install /home/charizard/Open/terminal-codelearn/node_modules/pty.js > node-gyp rebuild npm http GET https://registry.npmjs.org/commander npm http…
Charizard_
  • 1,054
  • 1
  • 8
  • 19
1
2 3
24 25