[starnix][devpts] Implement TIOCGSID ioctl

Return the controlling session ID for a terminal when handling TIOCGSID.
When called on the replica terminal, verify that the calling process
belongs to the terminal's controlling session before returning the
session ID; when called on the main terminal, return the controlling
session ID regardless of the caller's session.

Bug: 322894076, 564607149
Test: fx test starnix-devpts-tests --test-filter "*tiocgsid*"
Test: fx test pty_test --test-filter "*GetSessionId*"
Change-Id: I89f5254deb89cbc784fa1a21118c6b96a2e47f48
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1848119
Reviewed-by: Nathaniel Manista <nathaniel@google.com>
Commit-Queue: Benjamin Lerman <qsr@google.com>
Fuchsia-Auto-Submit: Benjamin Lerman <qsr@google.com>
Presubmit-Verified: fuchsia-internal-scoped@luci-project-accounts.iam.gserviceaccount.com <fuchsia-internal-scoped@luci-project-accounts.iam.gserviceaccount.com>
2 files changed