Questions tagged [controlling-terminal]

The "controlling terminal" is an attribute of a process that identifies the terminal device that affects it with regards to "job control". It typically affects processes that run inside a terminal or open a terminal device.

Controlling terminal is a terminal that is attached to a process to send it signals like Ctrl-C from user.

A process can be run without a controlling terminal, see Process without a controlling terminal. Processes without controlling terminal are marked with ?? in the ps output.

https://en.wikipedia.org/wiki/POSIX_terminal_interface#Controlling_terminals_and_process_groups

19 questions
24
votes
4 answers

Please explain this output of ps -ef command?

A part of the output from the ps -ef command is given below : UID PID PPID C STIME TTY TIME CMD root 1 0 0 2012 ? 00:00:01 init [3] root 2 1 0 2012 ? 00:00:01 [migration/0] root …
Geek
  • 6,548
  • 15
  • 46
  • 70
21
votes
2 answers

Concept of controlling terminal in Unix

Can some one please explain in an easy to understand way the concept of controlling terminal in unix and unix like systems ? Is it related to a session ? If yes, then how ?
Geek
  • 6,548
  • 15
  • 46
  • 70
15
votes
2 answers

How to get the real name of the controlling terminal?

How can one get the real name of the controlling terminal (if there is one, else an error) as a pathname? By "real name", I mean not /dev/tty, which cannot be used by other arbitrary processes to refer to the same terminal. I prefer the answer as a…
vinc17
  • 11,912
  • 38
  • 45
11
votes
2 answers

How can I redirect the output of a C program from /dev/tty to /dev/null?

Consider this sample C program which writes to /dev/tty and doesn't have command line options to make it not do so. #include int main (void) { FILE* fout = fopen("/dev/tty", "w"); fprintf(fout, "Hello, World!\n"); …
Firmin Martin
  • 337
  • 1
  • 11
10
votes
3 answers

Invoke a command/script disconnected from the controlling terminal?

I'm investigating the behaviour of a script that is normally run as an automated process (e.g. cron, Jenkins). The script can (eventually) invoke commands that behave differently (seeking user input) when run interactively; for example, patch will…
ecatmur
  • 245
  • 2
  • 9
9
votes
3 answers

Background, zombie, daemon and without ctty - are these concepts connected?

How these process concepts are related together - background, zombie, daemon and without controlling terminal? I feel that they are somehow close, especially through the concept of controlling terminal, but there is still not much info for me to…
8
votes
2 answers

what relations are between my current controlling terminal and `/dev/tty`?

On Lubuntu 18.04, I run a shell in lxterminal. Its controlling terminal is the current pseudoterminal slave: $ tty /dev/pts/2 I would like to know what relations are between my current controlling terminal /dev/pts/2 and /dev/tty. /dev/tty acts…
Tim
  • 98,580
  • 191
  • 570
  • 977
4
votes
1 answer

Process without a controlling terminal

What happens with process when it is run without a controlling terminal? How is that process different from a standard processes? What features does it lose and what does it acquire? UPDATE #1 The question listed as a possible duplicate: Concept of…
anatoly techtonik
  • 2,514
  • 4
  • 24
  • 37
3
votes
0 answers

Controlling terminal of a display server

When I login on a Fedora 31 workstation and run the ps command, I see the below output; for an X session: PID TT CMD ... 1 ? /usr/lib/systemd/systemd --switched-root --system --deserialize 29 ... 820 ? /usr/sbin/gdm 1305 ? …
detic
  • 33
  • 3
3
votes
1 answer

Does keyboard input always go through a controlling terminal?

Am I right that all input typed from the keyboard goes through a controlling terminal? That means that if a program is run without a controlling terminal, it won't be able to receive any user input. Is that right for every kind of program in…
anatoly techtonik
  • 2,514
  • 4
  • 24
  • 37
3
votes
1 answer

List all processes without controlling terminal (only)?

Is there a portable way to do this? On Linux, I can use ps a -N but this option isn't available on other (POSIX) systems. Of course I can use grep '^?' with, say, -o tty,... but is there something more reliable?
pashazz
  • 31
  • 1
2
votes
1 answer

Why can't bash map ^C to intr signal if invoked as init?

If I make the bash as the first process invoked (i.e as init), as a result it will display the following: init: cannot set terminal process group (-1): Inappropriate ioctl for device init: no job control in this shell And no signals (e.g ^C, ^Z)…
Li-Guangda
  • 257
  • 2
  • 3
  • 11
2
votes
0 answers

Is `controlling terminal` solely for user control?

I can kill processes and send signals to them with kill, so I don't need controlling terminal (or ctty) for that. So.. is the purpose of controlling terminal is solely for reacting to nudges from user? Transforming Ctrl-C key press into SIGINT…
anatoly techtonik
  • 2,514
  • 4
  • 24
  • 37
2
votes
0 answers

How do I assign the controlling terminal to other process?

I use TIOCSCTTY to forcibly take over the controlling terminal in other "remote" application. But after the application finishes running, controlling terminal gets orphaned and bash stops reacting to Ctrl+C until I restart it with bash$ exec…
Vi.
  • 5,528
  • 7
  • 34
  • 68
1
vote
2 answers

Can a (non-)controlling process detach its controlling terminal by closing its file descriptor?

In a process session with a controlling terminal, if the controlling process closes the file descriptor of the controlling terminal, does the process session become detached from the controlling terminal, i.e. not have any controlling…
Tim
  • 98,580
  • 191
  • 570
  • 977
1
2