Line 24... |
Line 24... |
/*
|
/*
|
* I really dislike using stuff beginning with '_'
|
* I really dislike using stuff beginning with '_'
|
* They are suppose to be reserved for the compiler
|
* They are suppose to be reserved for the compiler
|
* as explained in C standards.
|
* as explained in C standards.
|
*/
|
*/
|
|
#if HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
#define _XOPEN_SOURCE /* grantpt() and al. */
|
#define _XOPEN_SOURCE /* grantpt() and al. */
|
#define _GNU_SOURCE /* on_exit */
|
#define _GNU_SOURCE /* on_exit */
|
|
|
#include <sys/types.h> /* waitpid() */
|
#include <sys/types.h> /* waitpid() */
|
#include <sys/wait.h> /* waitpid() */
|
#include <sys/wait.h> /* waitpid() */
|
Line 36... |
Line 40... |
#include <unistd.h> /* close() */
|
#include <unistd.h> /* close() */
|
#include <fcntl.h> /* O_RDWR */
|
#include <fcntl.h> /* O_RDWR */
|
#include <string.h> /* strchr() */
|
#include <string.h> /* strchr() */
|
|
|
#ifndef __CYGWIN__
|
#ifndef __CYGWIN__
|
|
#if HAVE_SYS_STROPTS_H
|
#include <sys/stropts.h> /* grantpt(), unlockpt() */
|
#include <sys/stropts.h> /* grantpt(), unlockpt() */
|
|
#endif
|
#include <libgen.h> /* basename() */
|
#include <libgen.h> /* basename() */
|
#endif /* __CYGWIN__ */
|
#endif /* __CYGWIN__ */
|
|
|
#include <termios.h> /* struct termios and al. */
|
#include <termios.h> /* struct termios and al. */
|
#include <signal.h> /* signal() and al. */
|
#include <signal.h> /* signal() and al. */
|
Line 107... |
Line 113... |
char *arglist;
|
char *arglist;
|
|
|
retval->fds.fdin = -1;
|
retval->fds.fdin = -1;
|
retval->fds.fdout = -1;
|
retval->fds.fdout = -1;
|
retval->pid = -1;
|
retval->pid = -1;
|
|
|
|
#if defined(HAS_ON_EXIT)
|
/* reset cause exit(1), leaving an xterm opened */
|
/* reset cause exit(1), leaving an xterm opened */
|
on_exit(xterm_exit, retval);
|
on_exit(xterm_exit, retval);
|
|
#endif
|
|
|
i = 2;
|
i = 2;
|
arglist = (char*)input;
|
arglist = (char*)input;
|
retval->argv = malloc(sizeof(char*) * MAX_XTERM_ARGS);
|
retval->argv = malloc(sizeof(char*) * MAX_XTERM_ARGS);
|
if (!retval->argv) {
|
if (!retval->argv) {
|
Line 134... |
Line 143... |
|
|
|
|
|
|
static int xterm_open(void * data)
|
static int xterm_open(void * data)
|
{
|
{
|
|
#if defined(HAS_GRANTPT) && defined(HAS_UNLOCKPT) && defined(HAS_PTSNAME)
|
struct xterm_channel * xt = data;
|
struct xterm_channel * xt = data;
|
int master, retval;
|
int master, retval;
|
char * slavename;
|
char * slavename;
|
struct termios termio;
|
struct termios termio;
|
char arg[64], * fin;
|
char arg[64], * fin;
|
Line 164... |
Line 174... |
}
|
}
|
|
|
xt->fds.fdout = xt->fds.fdin = open(slavename, O_RDWR);
|
xt->fds.fdout = xt->fds.fdin = open(slavename, O_RDWR);
|
if(xt->fds.fdout < 0) goto closemastererror;
|
if(xt->fds.fdout < 0) goto closemastererror;
|
|
|
#if !defined(linux) && !defined(__CYGWIN__)
|
//#if !defined(linux) && !defined(__CYGWIN__)
|
|
#if defined(I_PUSH)
|
/* Linux does not support STREAMS-style line discipline, even with LiS. */
|
/* Linux does not support STREAMS-style line discipline, even with LiS. */
|
retval = ioctl(xt->fds.fdin, I_PUSH, "ptem");
|
retval = ioctl(xt->fds.fdin, I_PUSH, "ptem");
|
if(retval < 0) goto closeslaveerror;
|
if(retval < 0) goto closeslaveerror;
|
|
|
retval = ioctl(xt->fds.fdin, I_PUSH, "ldterm");
|
retval = ioctl(xt->fds.fdin, I_PUSH, "ldterm");
|
Line 224... |
Line 235... |
|
|
closemastererror:
|
closemastererror:
|
close(master);
|
close(master);
|
xt->pid = xt->fds.fdin = xt->fds.fdout = -1;
|
xt->pid = xt->fds.fdin = xt->fds.fdout = -1;
|
return -1;
|
return -1;
|
|
|
|
#else
|
|
/* I don't see how this stuff should be working on a system that doesn't know
|
|
grantpt(), unlockpt(), ptsname(). Mac OS X also does not have /dev/ptmx.
|
|
-hpanther
|
|
*/
|
|
return -1;
|
|
#endif
|
}
|
}
|
|
|
struct channel_ops xterm_channel_ops =
|
struct channel_ops xterm_channel_ops =
|
{
|
{
|
init: xterm_init,
|
init: xterm_init,
|