[newlib-cygwin] Cygwin: ctty: Add comments for the special values: -1 and -2.
Takashi Yano
tyan0@sourceware.org
Tue Jan 10 13:15:57 GMT 2023
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3b7df69aaa5752f78537eafa5838f65a1ddfc938
commit 3b7df69aaa5752f78537eafa5838f65a1ddfc938
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Tue Jan 10 22:04:40 2023 +0900
Cygwin: ctty: Add comments for the special values: -1 and -2.
_pinfo::ctty has two special values other than the device id of
the allocated ctty:
-1: CTTY is not initialized yet. Can be associated with the TTY
which is associated with the session leader.
-2: CTTY has been released by setsid(). Can be associate only with
new TTY which is not associated with any other session as CTTY,
but cannot be associate with the TTYs already associated with
other sessions.
This patch adds the comments in some source files.
Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signedoff-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diff:
---
winsup/cygwin/pinfo.cc | 5 ++++-
winsup/cygwin/syscalls.cc | 4 +++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index ece346037..fc618b9b8 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -97,7 +97,7 @@ pinfo_init (char **envp, int envc)
myself.thisproc (NULL);
myself->pgid = myself->sid = myself->pid;
- myself->ctty = -1;
+ myself->ctty = -1; /* -1 means not initialized yet. */
myself->uid = ILLEGAL_UID;
myself->gid = ILLEGAL_GID;
environ_init (NULL, 0); /* call after myself has been set up */
@@ -531,6 +531,9 @@ _pinfo::set_ctty (fhandler_termios *fh, int flags)
if (fh && (ctty <= 0 || ctty == tc.ntty) && !(flags & O_NOCTTY))
{
if (tc.getsid () && tc.getsid () != sid && ctty == -2)
+ /* ctty == -2 means CTTY has been released by setsid().
+ Can be associated only with a new TTY which is not
+ associated with any other session. */
; /* Do nothing if another session is associated with the TTY. */
else
{
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index fff8af009..15ddbb0a8 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1176,7 +1176,9 @@ setsid (void)
syscall_printf ("hmm. pgid %d pid %d", myself->pgid, myself->pid);
else
{
- myself->ctty = -2;
+ myself->ctty = -2; /* -2 means CTTY has been released by setsid().
+ Can be associated only with a new TTY which
+ is not associated with any session. */
myself->sid = myself->pid;
myself->pgid = myself->pid;
if (cygheap->ctty)
More information about the Cygwin-cvs
mailing list