From c70acbb1a3b14ba1131807023f35416e2d79f72f Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 3 Dec 2010 20:28:24 +0000 Subject: [PATCH] implement openpty for sun --- src/node_stdio.cc | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/node_stdio.cc b/src/node_stdio.cc index c649b8ffe1..213bd33b0a 100644 --- a/src/node_stdio.cc +++ b/src/node_stdio.cc @@ -5,14 +5,17 @@ #include #include #include -#ifdef __APPLE__ -#include +#if defined(__APPLE__) +# include +#elif defined(__sun) +# include // for openpty ioctls #else -#include +# include #endif #include #include +#include using namespace v8; namespace node { @@ -199,11 +202,29 @@ static Handle OpenPTY(const Arguments& args) { int master_fd, slave_fd; +#ifdef __sun + +typedef void (*sighandler)(int); + // TODO move to platform files. + master_fd = open("/dev/ptmx", O_RDWR | O_NOCTTY); + sighandler sig_saved = signal(SIGCHLD, SIG_DFL); + grantpt(master_fd); + unlockpt(master_fd); + signal(SIGCHLD, sig_saved); + char *slave_name = ptsname(master_fd); + slave_fd = open(slave_name, O_RDWR); + ioctl(slave_fd, I_PUSH, "ptem"); + ioctl(slave_fd, I_PUSH, "ldterm"); + ioctl(slave_fd, I_PUSH, "ttcompat"); + +#else + int r = openpty(&master_fd, &slave_fd, NULL, NULL, NULL); if (r == -1) { return ThrowException(ErrnoException(errno, "openpty")); } +#endif Local a = Array::New(2);