I have read that a process get its input and output from the terminal that its session is related to.

So does that mean that if I changed the session of a process, the stdin and stdout of the process change (because now effectively the process terminal has changed)?

This is where I read that.

  • What exactly do you mean by 'change the session of a process'?
    – DopeGhoti
    Commented May 17, 2017 at 20:20
  • @DopeGhoti As in a session has one or many process groups, and a process group has one or many processes.
    – Steve
    Commented May 17, 2017 at 20:25
  • "Although the controlling terminal for a session can be changed, this is usually done only by processes that manage a user's initial logging in to a system. Information on how to change a session's controlling tty appears in Chapter 16, on pages 338-339." — from that same page...
    – derobert
    Commented May 17, 2017 at 20:52

1 Answer 1


The standard input and output are typically connected to a concrete terminal line, e.g. /dev/pts/5. You can see it e.g. under /proc/12345/fd (the target of the symbolic links) (replace 12345 by the actual process ID). There's absolutely no way this target could automatically change to something else. In order to change these, the said file descriptors need to be explicitly closed and new ones explicitly opened.

I'm not sure what happens in the unlikely/unusual case that someone does some special tricks and somehow the standard input and output point to /dev/tty. I don't think I've ever seen such a thing. I see a chance that your assumption might be correct and effectively the input and output terminals might change in this case.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .