Print this page
14249 pseudo-terminal nomenclature should reflect POSIX
Change-Id: Ib4a3cef899ff4c71b09cb0dc6878863c5e8357bc
@@ -40,17 +40,17 @@
void dooutput();
void doshell();
void fixtty();
void fail();
void done() __NORETURN;
-void getmaster();
-void getslave();
+void getmanager();
+void getsubsid();
char *shell;
FILE *fscript;
-int master; /* file descriptor for master pseudo-tty */
-int slave; /* file descriptor for slave pseudo-tty */
+int manager; /* file descriptor for manager pseudo-tty */
+int subsid; /* file descriptor for subsidiary pseudo-tty */
int child;
int subchild;
char *fname = "typescript";
void sigwinch();
void finish();
@@ -57,11 +57,11 @@
struct termios b;
struct winsize size;
int lb;
int l;
-char *mptname = "/dev/ptmx"; /* master pseudo-tty device */
+char *mptname = "/dev/ptmx"; /* manager pseudo-tty device */
int aflg;
int
main(int argc, char *argv[])
@@ -101,11 +101,11 @@
perror(fname);
fail();
}
setbuf(fscript, NULL);
chown(fname, ruidt, gidt);
- getmaster();
+ getmanager();
printf(gettext("Script started, file is %s\n"), fname);
fixtty();
(void) signal(SIGCHLD, finish);
child = fork();
@@ -144,11 +144,11 @@
continue;
} else {
break;
}
}
- (void) write(master, ibuf, cc);
+ (void) write(manager, ibuf, cc);
}
done();
}
void
@@ -155,11 +155,11 @@
sigwinch()
{
struct winsize ws;
if (ioctl(0, TIOCGWINSZ, &ws) == 0)
- (void) ioctl(master, TIOCSWINSZ, &ws);
+ (void) ioctl(manager, TIOCSWINSZ, &ws);
}
#include <sys/wait.h>
void
@@ -188,11 +188,11 @@
(void) close(0);
tvec = time((time_t *)0);
strftime(tbuf, BUFSIZ, "%c", localtime(&tvec));
fprintf(fscript, gettext("Script started on %s\n"), tbuf);
for (;;) {
- cc = read(master, obuf, sizeof (obuf));
+ cc = read(manager, obuf, sizeof (obuf));
if (cc <= 0)
break;
(void) write(1, obuf, cc);
(void) fwrite(obuf, 1, cc, fscript);
}
@@ -202,17 +202,17 @@
void
doshell()
{
setpgrp(); /* relinquish control terminal */
- getslave();
- (void) close(master);
+ getsubsid();
+ (void) close(manager);
(void) fclose(fscript);
- (void) dup2(slave, 0);
- (void) dup2(slave, 1);
- (void) dup2(slave, 2);
- (void) close(slave);
+ (void) dup2(subsid, 0);
+ (void) dup2(subsid, 1);
+ (void) dup2(subsid, 2);
+ (void) close(subsid);
execl(shell, shell, "-i", (char *)0);
perror(shell);
fail();
}
@@ -247,24 +247,24 @@
if (subchild) {
tvec = time((time_t *)0);
strftime(tbuf, BUFSIZ, "%c", localtime(&tvec));
fprintf(fscript, gettext("\nscript done on %s\n"), tbuf);
(void) fclose(fscript);
- (void) close(master);
+ (void) close(manager);
} else {
(void) ioctl(0, TCSETSW, (char *)&b);
printf(gettext("Script done, file is %s\n"), fname);
}
exit(0);
}
void
-getmaster()
+getmanager()
{
struct stat stb;
- if ((master = open(mptname, O_RDWR)) >= 0) { /* a pseudo-tty is free */
+ if ((manager = open(mptname, O_RDWR)) >= 0) { /* a pseudo-tty is free */
(void) ioctl(0, TCGETS, (char *)&b);
(void) ioctl(0, TIOCGWINSZ, (char *)&size);
return;
} else { /* out of pseudo-tty's */
perror(mptname);
@@ -272,23 +272,23 @@
fail();
}
}
void
-getslave()
+getsubsid()
{
- char *slavename; /* name of slave pseudo-tty */
+ char *subsidname; /* name of subsidiary pseudo-tty */
- grantpt(master); /* change permissions of slave */
- unlockpt(master); /* unlock slave */
- slavename = ptsname(master); /* get name of slave */
- slave = open(slavename, O_RDWR); /* open slave */
- if (slave < 0) { /* error on opening slave */
- perror(slavename);
+ grantpt(manager); /* change permissions of subsidiary */
+ unlockpt(manager); /* unlock subsidiary */
+ subsidname = ptsname(manager); /* get name of subsidiary */
+ subsid = open(subsidname, O_RDWR); /* open subsidiary */
+ if (subsid < 0) { /* error opening subsidiary */
+ perror(subsidname);
fail();
}
- ioctl(slave, I_PUSH, "ptem"); /* push pt hw emulation module */
- ioctl(slave, I_PUSH, "ldterm"); /* push line discipline */
+ ioctl(subsid, I_PUSH, "ptem"); /* push pt hw emulation module */
+ ioctl(subsid, I_PUSH, "ldterm"); /* push line discipline */
- (void) ioctl(slave, TCSETSF, (char *)&b);
- (void) ioctl(slave, TIOCSWINSZ, (char *)&size);
+ (void) ioctl(subsid, TCSETSF, (char *)&b);
+ (void) ioctl(subsid, TIOCSWINSZ, (char *)&size);
}