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.

420 questions
8
votes
2 answers

Running vi from within haskell program (dealing with ptys)

I'm trying to write a logging shell; e.g. one that captures data about commands that are being run in a structured format. To do this, I'm using readline to read in commands and then executing them in a subshell whilst capturing things such as the…
Impredicative
  • 5,039
  • 1
  • 17
  • 43
8
votes
2 answers

-serial pty in qemu, how to open?

I am running qemu with -serial pty option, and qemu gave this message char device redirected to /dev/pts/1 however, it doesn't generate new window, I can do cat on pts1 from different window, but then I can't input any character to it. Is there…
Isa A
  • 1,342
  • 13
  • 31
8
votes
4 answers

Using subprocess with select and pty hangs when capturing output

I'm trying to write a python program that is able to interact with other programs. That means sending stdin and receiving stdout data. I cannot use pexpect (although it definitely inspired some of the design). The process I'm using right now is…
ravenac95
  • 3,557
  • 1
  • 20
  • 21
7
votes
2 answers

Troubleshooting OSError: out of pty devices

From time to time I'm getting an OSError exception with the message 'out of pty devices' when calling pty.openpty() (it's happening when a bunch of instances of my scripts run concurrently). What is the limit that I'm hitting? How can I get around…
kdt
  • 27,905
  • 33
  • 92
  • 139
7
votes
1 answer

Pty doesn't get closed, althoguh close() syscall is called

I'm implementing features of an ssh server, so given a shell request I open a pty-tty pair. A snippet: import ( "github.com/creack/pty" ... ) func attachPty(channel ssh.Channel, shell *exec.Cmd) { mypty, err := pty.Start(shell) go…
Noam Solovechick
  • 1,127
  • 2
  • 15
  • 29
7
votes
1 answer

Python pty.spawn stdin not echoed but redirected to master's stdout

I want to call a program from Python and make it believe that its stdout is a tty even when Python's process stdout is attached to a pipe. So I used the pty.spawn function to achieve that, which can be verified from the following : $ python -c…
Abhishek Kedia
  • 867
  • 6
  • 17
7
votes
0 answers

tcgetpgrp returns 0 -- implications?

Context: I'm working on an application that needs to determine whether the pseudo-terminal opened by a process is its controlling terminal. I'm trying to use the tcgetpgrp() libc/system call to achieve this. Observations: 1) I noticed that…
userRG
  • 99
  • 7
7
votes
7 answers

How can I spy on communication between a process and a terminal?

I have a Linux process developed by a third-party that communicates with a terminal. For debugging I want to see the communication going back in forth. One might think cat would do the trick (to see one direction): ./third-party-app & cat…
jbarlow
  • 1,500
  • 14
  • 21
7
votes
3 answers

segmentation fault on pseudo terminal

I get a segmentation fault with this code on fprintf: #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include…
muebau
  • 152
  • 7
7
votes
1 answer

When pty [Pseudo terminal] slave fd settings are changed by "tcsetattr" , how can the master end capture this event without delay?

The slave fd is used by another application (say "A") as a serial port device . A will set its baud rate/stop bit etc. My app needs this information . BTW, is there any way for a process that has only the master fd open to be notified of all…
Shazoo
  • 73
  • 5
7
votes
1 answer

Why does OpenSSH RequestTTY cause stderr redirected to stdout?

When running the same ssh command with -T and -t, any stderr output arrives on stderr vs. stdout, respectively. No pty allocated: ssh -T user@host "echo >&2 foo" 1>/tmp/out 2>/tmp/err Output is written to /tmp/err. With pty allocation: ssh -t…
gabor
  • 400
  • 3
  • 12
7
votes
1 answer

How do I set the terminal foreground process group for a process I'm running under a pty?

I've written a simple wrapper script for repeating commands when they fail called retry.py. However as I want to see the output of child command I've had to pull some pty tricks. This works OK for programs like rsync but others like scp apply…
stsquad
  • 5,712
  • 3
  • 36
  • 54
6
votes
1 answer

How does `SIGWINCH` pass through Bash?

If I run a program in Bash that listens for SIGWINCH, and I resize the terminal that Bash is running in, then the program will receive SIGWINCH. I would like to know how this signal gets relayed to the program running under Bash. Here is my…
Sean Kelleher
  • 1,952
  • 1
  • 23
  • 34
6
votes
3 answers

Socat pseudo terminal: Can you make use of data lines (DTR, RTS etc)?

I'm creating a virtual serial port using socat. socat -d -d pty,echo=0,raw pty,echo=0,raw That works as expected so far. Using echo/cat I can send/receice text etc. But what about signal lines like DTR or RTS? How would I get / set the state of…
Forivin
  • 14,780
  • 27
  • 106
  • 199
6
votes
1 answer

Golang reading from stdin, how to detect special keys (enter, backspace... etc)

I have the following program that reads user input from stdin: var input string = "" exec.Command("stty", "-F", "/dev/tty", "cbreak", "min", "1").Run() exec.Command("stty", "-F", "/dev/tty", "-echo").Run() var b…
George H
  • 412
  • 3
  • 6
  • 12
1 2
3
27 28