2

While reading "Advanced Programming in the Unix Environment", it appears to me that those two functions do exactly the same thing.

They both return the same result to the calling process.

So why bother design two of them?


Thanks larsmans. But if a process wants to know its session id, it can simply do getsid(0), under what circumstance does a process need to call tcgetsid(pid) to know its session id?

Rui Liu
  • 376
  • 4
  • 9

1 Answers1

3

tcgetsid returns the process group ID of the session for a terminal, denoted by a file descriptor.

getsid returns the same for a process, denotes by its PID.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • Thanks larsmans. But if a process wants to know its session id, it can simply do getsid(0), under what circumstance does a process need to call tcgetsid(pid) to know its session id? – Rui Liu Nov 07 '11 at 16:45