* enable pty support for platforms that do not have openpty(), but do
have pty support in general. This commit was SVN r9250.
Этот коммит содержится в:
родитель
b4e7f38360
Коммит
d0f5f8a242
@ -645,15 +645,15 @@ AC_CACHE_SAVE
|
||||
ompi_show_title "Header file tests"
|
||||
|
||||
AC_CHECK_HEADERS([alloca.h aio.h arpa/inet.h dirent.h \
|
||||
dlfcn.h execinfo.h err.h fcntl.h inttypes.h libgen.h libutil.h \
|
||||
netdb.h netinet/in.h netinet/tcp.h \
|
||||
dlfcn.h execinfo.h err.h fcntl.h grp.h inttypes.h libgen.h \
|
||||
libutil.h netdb.h netinet/in.h netinet/tcp.h \
|
||||
poll.h pthread.h pty.h pwd.h sched.h stdint.h \
|
||||
string.h strings.h stropts.h sys/fcntl.h sys/ipc.h \
|
||||
sys/ioctl.h sys/mman.h sys/param.h sys/queue.h \
|
||||
sys/resource.h sys/select.h sys/socket.h sys/sockio.h \
|
||||
sys/stat.h sys/statvfs.h sys/time.h sys/tree.h \
|
||||
sys/types.h sys/uio.h sys/utsname.h sys/wait.h syslog.h \
|
||||
time.h termios.h ulimit.h unistd.h util.h malloc.h])
|
||||
time.h termios.h ulimit.h unistd.h util.h utmp.h malloc.h])
|
||||
|
||||
# Needed to work around Darwin requiring sys/socket.h for
|
||||
# net/if.h
|
||||
@ -780,7 +780,7 @@ OMPI_CHECK_FUNC_LIB([dirname], [gen])
|
||||
# Darwin doesn't need -lm, as it's a symlink to libSystem.dylib
|
||||
OMPI_CHECK_FUNC_LIB([ceil], [m])
|
||||
|
||||
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty htonl ntohl htons ntohs getpwuid fork waitpid execve pipe setsid mmap mallopt])
|
||||
AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty htonl ntohl htons ntohs getpwuid fork waitpid execve pipe ptsname setsid mmap mallopt])
|
||||
|
||||
#
|
||||
# Make sure we can copy va_lists (need check declared, not linkable)
|
||||
|
@ -47,6 +47,7 @@ headers = \
|
||||
path.h \
|
||||
pow2.h \
|
||||
printf.h \
|
||||
opal_pty.h \
|
||||
qsort.h \
|
||||
show_help.h \
|
||||
show_help_lex.h \
|
||||
@ -75,6 +76,7 @@ libopalutil_la_SOURCES = \
|
||||
path.c \
|
||||
pow2.c \
|
||||
printf.c \
|
||||
opal_pty.c \
|
||||
qsort.c \
|
||||
show_help.c \
|
||||
show_help_lex.l \
|
||||
|
@ -15,7 +15,6 @@
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -75,7 +74,15 @@
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_GRP_H
|
||||
#include <grp.h>
|
||||
#endif
|
||||
#ifdef HAVE_PTY_H
|
||||
#include <pty.h>
|
||||
#endif
|
||||
#ifdef HAVE_UTMP_H
|
||||
#include <utmp.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTSNAME
|
||||
# include <stdlib.h>
|
||||
@ -84,55 +91,41 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UTIL_H
|
||||
#include <util.h>
|
||||
#endif
|
||||
|
||||
#include "opal/util/opal_pty.h"
|
||||
|
||||
/* The only public interface is openpty - all others are to support
|
||||
openpty() */
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* yeah, let's assume for the moment that ptys don't work on windows */
|
||||
|
||||
int opal_openpty(int *amaster, int *aslave, char *name,
|
||||
struct termios *termp, struct winsize *winp)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#elif defined(HAVE_OPENPTY)
|
||||
|
||||
int opal_openpty(int *amaster, int *aslave, char *name,
|
||||
struct termios *termp, struct winsize *winp)
|
||||
{
|
||||
return openpty(amaster, aslave, name, termp, winp);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* implement openpty in terms of ptym_open and ptys_open */
|
||||
|
||||
static int ptym_open(char *pts_name);
|
||||
static int ptys_open(int fdm, char *pts_name);
|
||||
|
||||
|
||||
int opal_forkpty(int *amaster, char *name, struct termios *termp,
|
||||
struct winsize *winp)
|
||||
{
|
||||
int master, slave;
|
||||
pid_t pid;
|
||||
|
||||
if (opal_openpty(&master, &slave, name, termp, winp) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid < 0) { /* error */
|
||||
return -1;
|
||||
} else if (pid > 0) { /* parent */
|
||||
*amaster = master;
|
||||
close(slave);
|
||||
} else { /* child */
|
||||
close(master);
|
||||
opal_login_tty(slave);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
||||
int opal_login_tty(int fd)
|
||||
{
|
||||
setsid(2);
|
||||
#ifdef TIOCSCTTY
|
||||
if (ioctl(fd, TIOCSCTTY, (char *) NULL) == -1) {
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
dup2(fd, 0);
|
||||
dup2(fd, 1);
|
||||
dup2(fd, 2);
|
||||
if (fd > 2) {
|
||||
close(fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int opal_openpty(int *amaster, int *aslave, char *name,
|
||||
struct termios *termp, struct winsize *winp)
|
||||
{
|
||||
@ -276,3 +269,5 @@ static int ptys_open(int fdm, char *pts_name)
|
||||
return fds;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* #ifdef HAVE_OPENPTY */
|
36
opal/util/opal_pty.h
Обычный файл
36
opal/util/opal_pty.h
Обычный файл
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
* of Tennessee Research Foundation. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#ifndef OPAL_UTIL_PTY_H
|
||||
#define OPAL_UTIL_PTY_H
|
||||
|
||||
#ifdef HAVE_UTIL_H
|
||||
#include <util.h>
|
||||
#endif
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
# include <termios.h>
|
||||
#else
|
||||
# ifdef HAVE_TERMIO_H
|
||||
# include <termio.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int opal_openpty(int *amaster, int *aslave, char *name,
|
||||
struct termios *termp, struct winsize *winp);
|
||||
|
||||
#endif /* OPAL_UTIL_PTY_H */
|
@ -57,6 +57,7 @@
|
||||
|
||||
#include "orte/orte_constants.h"
|
||||
#include "opal/util/output.h"
|
||||
#include "opal/util/opal_pty.h"
|
||||
#include "orte/mca/errmgr/errmgr.h"
|
||||
#include "orte/mca/iof/iof.h"
|
||||
#include "orte/mca/ns/ns.h"
|
||||
@ -67,16 +68,16 @@ orte_iof_base_setup_prefork(orte_iof_base_io_conf_t *opts)
|
||||
int ret;
|
||||
|
||||
/* first check to make sure we can do ptys */
|
||||
#if (! defined(HAVE_OPENPTY)) || (OMPI_ENABLE_PTY_SUPPORT == 0)
|
||||
#if !OMPI_ENABLE_PTY_SUPPORT
|
||||
opts->usepty = 0;
|
||||
#endif
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
#if defined(HAVE_OPENPTY) && OMPI_ENABLE_PTY_SUPPORT
|
||||
#if OMPI_ENABLE_PTY_SUPPORT
|
||||
if (opts->usepty) {
|
||||
ret = openpty(&(opts->p_stdout[0]), &(opts->p_stdout[1]),
|
||||
NULL, NULL, NULL);
|
||||
ret = opal_openpty(&(opts->p_stdout[0]), &(opts->p_stdout[1]),
|
||||
NULL, NULL, NULL);
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
|
@ -205,11 +205,7 @@ static int orte_pls_fork_proc(
|
||||
|
||||
/* should pull this information from MPIRUN instead of going with
|
||||
default */
|
||||
#if (! defined(HAVE_OPENPTY)) || (OMPI_ENABLE_PTY_SUPPORT == 0)
|
||||
opts.usepty = 0;
|
||||
#else
|
||||
opts.usepty = OMPI_ENABLE_PTY_SUPPORT;
|
||||
#endif
|
||||
|
||||
/* BWB - Fix post beta. Should setup stdin in orterun and
|
||||
make part of the app_context */
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user