pseudo-terminals

How can the master pty detect if a slave tty has exited?

I am using BSD style pty/tty pairs to implement running a sub shell. When the user exits the sub shell, how do I detect in the master process that this has occurred? I am using select(nfds, &read_fds, NULL, NULL, &timeout); with the master pty file descriptor set in the read_fds on the master side. ...

Calling fgets() on popen() of 'ssh' is flushing the beginning of stdin of the calling process (ptty issue)

Hello, I have now whittled this down to a minimal test case. Thus far I have been able to determine that this is an issue related to pseudo-terminals which come about with the pipe of ssh. Adding the '-t -t' to the ssh call improved things, in that now, it takes a second call to fgets() to cause the issue. I suspect that the stderr o...

Child process unable to read from created pseudo terminal

I'm trying to write an app that can login to SSH with a password, by using pseudo terminals. But if I write() to the master device then the data somehow does not appear in the slave device. Here's a simple test case: #include <sys/wait.h> #include <sys/types.h> #include <stdio.h> #include <unistd.h> #ifdef __linux__ #include <pty.h>...

How to send Ctrl-C control character or terminal hangup message to child process?

I have a child process which runs in a pseudo terminal. The parent process does not run as root, but the child process does, through su or sudo. Because of this it is not possible to send a signal to the child process to force it to exit. I want to force it to exit by one of these means: emulating a Ctrl-C. emulating a terminal hangup....

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 /dev/tty ...but it does not. Rather, cat will steal half of the data intended for the ...

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 several master/slave pty pairs, and then allows programs that were made to read from the se...

Characters not making it from a master to a slave pseudo-terminal

Hello, I am currently trying to send binary data out through pexpect. For some reason, the data gets through just find except for a 0x04, which is just skipped over. I tracked down the pexpect call to determine that all thats happening is an os.write() call to a file descriptor opened from a pty.fork() command. Any ideas? (example...

How to redirect a program that writes to tty?

This is the un-redirected output (if you don't know what module is, it doesn't matter much): $ module help null ----------- Module Specific Help for 'null' ----------------------- This module does absolutely nothing. It's meant simply as a place holder in your dot file initialization. Version 3.2.6 S...