rliu054 rliu054 - 1 year ago 85
C Question

Does tcgetsid, getsid achieve the same result?

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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download