tty

Catching a direct redirect to /dev/tty

I'm working on an application controller for a program that is spitting text directly to /dev/tty. This is a production application controller that must be able to catch all text going to the terminal. Generally, this isn't a problem. We simply redirect stdout and stderr. This particular application is making direct calls to echo and re...

How do *nix pseudo-terminals work ? What's the master/slave channel ?

I want to write a simple, dumb, X terminal emulator in C on a Linux system. At first, I just thought I would have to popen a shell and display its output. I checked xterm and rxvt code, and it looks a bit more complicated. First, I have to open a pseudo-terminal with openpty. So I look at the man page and see that openpty fills 2 file...

In Ubuntu Intrepid, what keypress will take me to tty13?

Trying out Ubuntu Intrepid, I have discovered that RightAlt+F1 doesn't take me to tty13. I've exhaustively tried every option presented to me in "dpkg-reconfigure console-setup", the best I've been able to manage thus far has been to have both Alt keys behave the same (LeftAlt+F1 and RightAlt+F1 both going to tty1). Please note that usi...

How can I create a loop between two TTYs?

Every Hello has a response. Second TTY will send a hello to the sender TTY and vice versa: echo 'echo hello > /dev/pts/1' > /dev/pts/0 The 1st receiver should send "hello" to the original sender, but it does not. What is wrong? [Clarification] I have two shells running. /dev/pts/1 is the initial sender. ...

ksh: how to probe stdin?

I want my ksh script to have different behaviors depending on whether there is something incoming through stdin or not: (1) cat file.txt | ./script.ksh (then do "cat <&0 >./tmp.dat" and process tmp.dat) vs. (2) ./script.ksh (then process $1 which must be a readable regular file) Checking for stdin to see if it is a terminal[ -t 0...

Getting exclusive access to a tty device from a root program on Linux

I have a program running as root on Linux, talking to a tty (actually an LCD implemented as a tty). The device for what it's worth is /dev/ttyUSB0. I'd like to have my program that writes to this device be able to have exclusive access to the device, so as to not have any interference from other instances of the program running at the sa...

Unable to have TTY switch for Ctrl-Alt F1 and Alt-F1...F6 in Mac

Problems: to have terminal mode for the keybinding Ctrl-Alt F1 to have TTY switch for Alt-F1...F6 Ubuntu has the above commands to move between different ttys. It seems that Mac does not have them activated. I did not find by Google any discussion about the topic. How can you activate the above functionalities in Mac? ...

Handling User-Break (UART Break) on a /dev/tty device in Linux

Here is some code sample, but the issue is that the signal handler is not called when a 'break' is sent over the serial line with 'putty'. #include <sys/ioctl.h> #include <termios.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/signal.h> #include <errno.h> #include <sys/types.h> #inclu...

how does a process know when it's been backgrounded?

When I scp a file, I can stop it with ^Z and put it in the background. When it's in the background it stops printing its progress but the copying continues. If I foreground it again, it resumes printing. How does it know? SIGTTOU? does that happen on a standard ptty? ...

How to create a pseudo-tty for reading output and writing to input

I am using fork() and execvp() to spawn a process that must believe it is connected to an interactive terminal for it to function properly. Once spawned, I want to capture all the output from the process, as well as be able to send input to the process. I suspect psuedo-ttys may help here. Does anyone have a snippet on how to do this?...

How can I figure out which tty file points to which USB-to-Serial device?

I have two legacy machines connected to a Linux box with USB using the ftdi_sio driver, to /dev/ttyUSB0 and /dev/ttyUSB1. The Linux box is relaying and analyzing the traffic between the machines. When the Linux box boots up, the machines are connected to the files pretty much randomly. The problem is to know which one is which. I could ...

Receiving key press and key release events in Linux terminal applications?

I would like to write a simple C program that will perform different actions based on both "key down" and "key up" events. This program will be run from inside rxvt. What library or mechanism should I use to access both key presses and releases? Is it true that reading /dev/tty will only provide key releases? Is this also true for termc...

Linux receive signal break for ttycontrol program

I would like to receive SIGINT if my process controlling /dev/ttyS2 receives BREAK on a serial port. I run this program from a shell. From what I discovered only "the terminal is the controlling terminal of a foreground process group, it will cause a SIGINT to be sent to this foreground process group" I tried make process making controll...

arrow key via stdin

Hi everybody, I'm trying to send an arrow key via the stdin to the bash: cat | /bin/bash then i am typing "echo hi" => "hi" appears on the console (of course without the quotes) then i press the arrow key up => ^[[A command not found appears Is it possible to send an arrow key to an program via the stdin ? The reason why i am asking...

bash script doesnt run correctly as background process

I have bash script which works well but when I send it back with nohup script & and close my terminal session then it's not working correctly. It only works well within my terminal session open. What could be possible reasons which affects my script run not correctly without my terminal session? Could it be one of the terminal variabl...

Where can I find TTY and curses documentation for Unix?

I'm working on automation tools for an ERP program running on SCO Unix. See my questions on Expect: http://stackoverflow.com/questions/1987302/tcl-expect-clear-screen-after-exit http://stackoverflow.com/questions/1988811/expect-get-variable-from-screen-region-based-on-row-and-column Where can I find (either locally or on the web) res...

getting tty of caller in signal handler in php

Hi all, I just wrote php daemon for my app and want to implement some output information generated on specified signal (SIGUSR1). I got signal handler in code pcntl_signal(SIGUSR1, array($this, 'signal_status')); and function handler prepared protected function signal_status($signal_number) { printf("blah\n"); } Everything...

detecting end of tty output

Hi I'm writing a psudo-terminal that can live in a tty and spawn a second tty which is filters input and output from I'm writing it in python for now, spawning the second tty and reading and writing is easy but when I read, the read does not end, it waits for more input. import subprocess pfd = subprocess.Popen(['/bin/sh'], shell=Tru...

Keyboard and Bluetooth killed when establishing FTDI USB Serial connection

Okay, when I establish a connection using LabVIEW or Python to my Arduino Duemilanove (ATMega328) either my Bluetooth or keyboard is killed. I am simply trying to establish a connection to /dev/cu.usbserial-A9007UZh (or tty.usbserial-A9007UZh, but that seems to kill the keyboard or bluetooth even after Terminal is shut down when using p...

How would I go about writing a Linux TTY sniffer?

For educational purposes (not that anyone should care about the motivations behind such an exercise) I'd like to write a program that can read/write to/from alternate tty/pty's. I've read papers (from the 1990's) but can't employ the implementation they use, on modern Linux/glibc I was hoping that someone had researched into this in the...