roken: Use ptsname_r() if we have it
This commit is contained in:

committed by
Jeffrey Altman

parent
ed6f3f1786
commit
beae9c3c43
@@ -529,7 +529,7 @@ AC_CHECK_FUNCS([ \
|
|||||||
getresgid \
|
getresgid \
|
||||||
getresuid \
|
getresuid \
|
||||||
grantpt \
|
grantpt \
|
||||||
ptsname \
|
ptsname_r \
|
||||||
rand \
|
rand \
|
||||||
setitimer \
|
setitimer \
|
||||||
setregid \
|
setregid \
|
||||||
|
@@ -694,9 +694,6 @@ static const char *const rcsid[] = { (const char *)rcsid, "@(#)" msg }
|
|||||||
/* This option is added by the NTMakefile if we have a <pthread.h>. */
|
/* This option is added by the NTMakefile if we have a <pthread.h>. */
|
||||||
/* #define HAVE_PTHREAD_H 1 */
|
/* #define HAVE_PTHREAD_H 1 */
|
||||||
|
|
||||||
/* Define to 1 if you have the `ptsname' function. */
|
|
||||||
/* #define HAVE_PTSNAME 1 */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <pty.h> header file. */
|
/* Define to 1 if you have the <pty.h> header file. */
|
||||||
/* #define HAVE_PTY_H 1 */
|
/* #define HAVE_PTY_H 1 */
|
||||||
|
|
||||||
|
@@ -123,7 +123,18 @@ open_pty(void)
|
|||||||
#ifdef HAVE_UNLOCKPT
|
#ifdef HAVE_UNLOCKPT
|
||||||
unlockpt(master);
|
unlockpt(master);
|
||||||
#endif
|
#endif
|
||||||
strlcpy(line, ptsname(master), sizeof(line));
|
#ifdef HAVE_PTSNAME_R
|
||||||
|
if (ptsname_r(master, line, sizeof(line)) == -1)
|
||||||
|
err("Failed to open the pty master %s", *q);
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
char *s = ptsname(master);
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
err("Failed to open the pty master %s", *q);
|
||||||
|
strlcpy(line, s, sizeof(line));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
slave = open(line, O_RDWR);
|
slave = open(line, O_RDWR);
|
||||||
if (slave < 0)
|
if (slave < 0)
|
||||||
errx(1, "failed to open slave when using %s", *q);
|
errx(1, "failed to open slave when using %s", *q);
|
||||||
|
Reference in New Issue
Block a user