openpty: adapt variable naming

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2020-06-19 23:54:07 +02:00
parent 8ed01f3c00
commit a143f4a563
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D
2 changed files with 20 additions and 18 deletions

View File

@ -34,43 +34,43 @@
#define _PATH_DEVPTMX "/dev/ptmx"
int openpty (int *amaster, int *aslave, char *name, struct termios *termp,
int openpty (int *aptmx, int *apts, char *name, struct termios *termp,
struct winsize *winp)
{
char buf[PATH_MAX];
int master, slave;
int ptmx, pts;
master = open(_PATH_DEVPTMX, O_RDWR);
if (master == -1)
ptmx = open(_PATH_DEVPTMX, O_RDWR);
if (ptmx == -1)
return -1;
if (grantpt(master))
if (grantpt(ptmx))
goto fail;
if (unlockpt(master))
if (unlockpt(ptmx))
goto fail;
if (ptsname_r(master, buf, sizeof buf))
if (ptsname_r(ptmx, buf, sizeof buf))
goto fail;
slave = open(buf, O_RDWR | O_NOCTTY);
if (slave == -1)
pts = open(buf, O_RDWR | O_NOCTTY);
if (pts == -1)
goto fail;
/* XXX Should we ignore errors here? */
if (termp)
tcsetattr(slave, TCSAFLUSH, termp);
tcsetattr(pts, TCSAFLUSH, termp);
if (winp)
ioctl(slave, TIOCSWINSZ, winp);
ioctl(pts, TIOCSWINSZ, winp);
*amaster = master;
*aslave = slave;
*aptmx = ptmx;
*apts = pts;
if (name != NULL)
strcpy(name, buf);
return 0;
fail:
close(master);
close(ptmx);
return -1;
}

View File

@ -27,10 +27,12 @@
#include <termios.h>
#include <sys/ioctl.h>
/* Create pseudo tty master slave pair with NAME and set terminal
attributes according to TERMP and WINP and return handles for both
ends in AMASTER and ASLAVE. */
extern int openpty (int *__amaster, int *__aslave, char *__name,
/*
* Create pseudo tty ptmx pts pair with @__name and set terminal
* attributes according to @__termp and @__winp and return handles for both
* ends in @__aptmx and @__apts.
*/
extern int openpty (int *__aptmx, int *__apts, char *__name,
const struct termios *__termp,
const struct winsize *__winp);