user9002947
user9002947

Reputation: 125

Is the "foreground process group" a property of the controlling terminal or a property of the session?

A session in Linux can have a controlling terminal.

What I am interested in knowing is when you set the foreground process group (using tcsetpgrp()) of a controlling terminal, is the variable that holds the process group id of the foreground process group belongs to the controlling terminal data structures or does it belong to the session data structures?

Upvotes: 2

Views: 508

Answers (1)

harmic
harmic

Reputation: 30577

tcsetpgrp() is implemented via the ioctl TIOCSPGRP on the tty device.

This ioctl in turn is implemented in the kernel function tiocspgrp, sets member pgrp of the struct tty_struct for the terminal.

In short, the foreground process group is stored in the tty data structure. Which makes sense, since the effect of the foreground process group is to identify which process(es) will receive signals from the tty when the user presses key combinations such as ctrl-C and ctrl-Z.

Upvotes: 2

Related Questions