Giter VIP home page Giter VIP logo

pty.js's People

Contributors

19h avatar aeosynth avatar apoco avatar chjj avatar clehner avatar dan-lightsource avatar heavyk avatar jacereda avatar joshwilsdon avatar marsup avatar mscdex avatar nightwing avatar peters avatar rauchg avatar rlidwka avatar tootallnate avatar vangie avatar y13i avatar zcbenz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pty.js's Issues

Ignoring result of chdir() function

  CXX(target) Release/obj.target/pty/src/unix/pty.o
../src/unix/pty.cc: In function ‘v8::Handle<v8::Value> PtyFork(const v8::Arguments&)’:
../src/unix/pty.cc:185:34: warning: ignoring return value of ‘int chdir(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
       if (strlen(cwd)) chdir(cwd);
                                  ^
  SOLINK_MODULE(target) Release/obj.target/pty.node
  SOLINK_MODULE(target) Release/obj.target/pty.node: Finished
  COPY Release/pty.node

Error: Symbol pty_module not found.

I use:
Red Hat Enterprise Linux Server release 4 (Tikanga) -- Linux version 2.6.18-164.el5
Python-2.7.3
node-v0.9.1
then execute "npm install pty.js" -- ok
but :
[root@bogon lib]# node

require('pty.js');
Error: Symbol pty_module not found.
at Object.Module._extensions..node (module.js:490:11)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object. (/root/node_modules/pty.js/lib/pty.js:8:11)
at Module._compile (module.js:454:26)
at Object.Module._extensions..js (module.js:472:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)


[root@bogon Release]# pwd
/root/node_modules/pty.js/build/Release
[root@bogon Release]# ls
linker.lock obj.target pty.node

and
in pty.js file I think may this not work:
var pty = require('../build/Release/pty.node');

Failed to install pty.js

I'm trying to install a node-js package which is dependent on pty.js. When installing it I get plenty of errors and a nice message suggesting me that the problem is in pty.js; So this is the output (excluded all download-notifications) when I run npm install -g pty.js --msvs_version=2013

  DebugClient.cc
  Agent.cc
  EventLoop.cc
  Coord.cc
  AgentAssert.cc
  Win32Console.cc
..\..\..\deps\winpty\agent\EventLoop.cc(69): error C2039: 'max' : is not a memb
er of 'std' [C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\build\deps
\winpty\winpty-agent.vcxproj]
..\..\..\deps\winpty\agent\EventLoop.cc(69): error C3861: 'max': identifier not
 found [C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\build\deps\winp
ty\winpty-agent.vcxproj]
  Terminal.cc
  main.cc
  ConsoleInput.cc
  NamedPipe.cc
  SmallRect.cc
..\..\..\deps\winpty\agent\NamedPipe.cc(153): error C2039: 'min' : is not a mem
ber of 'std' [C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\build\dep
s\winpty\winpty-agent.vcxproj]
..\..\..\deps\winpty\agent\NamedPipe.cc(153): error C3861: 'min': identifier no
t found [C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\build\deps\win
pty\winpty-agent.vcxproj]
..\..\..\deps\winpty\agent\NamedPipe.cc(222): error C2039: 'min' : is not a mem
ber of 'std' [C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\build\dep
s\winpty\winpty-agent.vcxproj]
..\..\..\deps\winpty\agent\NamedPipe.cc(222): error C3861: 'min': identifier no
t found [C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\build\deps\win
pty\winpty-agent.vcxproj]
..\..\..\deps\winpty\agent\NamedPipe.cc(229): error C2039: 'min' : is not a mem
ber of 'std' [C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\build\dep
s\winpty\winpty-agent.vcxproj]
..\..\..\deps\winpty\agent\NamedPipe.cc(229): error C3861: 'min': identifier no
t found [C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\build\deps\win
pty\winpty-agent.vcxproj]
  DebugClient.cc
  winpty.cc
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale(337): wa
rning C4530: C++ exception handler used, but unwind semantics are not enabled.
Specify /EHsc (..\..\..\deps\winpty\libwinpty\winpty.cc) [C:\Users\TestUser\AppDa
ta\Roaming\npm\node_modules\pty.js\build\deps\winpty\winpty.vcxproj]
     Creating library C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\b
  uild\Release\winpty.lib and object C:\Users\TestUser\AppData\Roaming\npm\node_m
  odules\pty.js\build\Release\winpty.exp
  Generating code
  Finished generating code
  winpty.vcxproj -> C:\Users\TestUser\AppData\Roaming\npm\node_modules\pty.js\bui
  ld\Release\\winpty.dll

pty.js doesn't work well with latest node-webkit (0.6.3)

I've compiled pty.js using nw-gyp as specified here:
https://github.com/rogerwang/nw-gyp#how-to-use

In the previous version of node-webkit (0.5.0) it worked fine.

During initialization of pty.js in node-webkit I get this error:
"Error: dlopen(/Users/[...]/pty.nw.js/build/Release/pty.node, 1): Symbol not found: _environ
  Referenced from: /Users/[...]/pty.nw.js/build/Release/pty.node
  Expected in: dynamic lookup

(I replaced the path with [...] for brevity)

Node webkit 0.6.3 runs node 0.10.12. Googling for the error I found that it must be some incompatibility issue between pty.js and node-webkit.

Thank you for your help!

Environment problems => investigation and solution ?

Hi !
First of all, thx for this wonderful work !!!

Now, there are some problems with the environment...
In fact, all the vars are passed without delimitors, soo cmd.exe can only see a big var with all the values (type SET and you'll see).

Agent read a wstring from pipe, and the serialize/unserialize process can enable us to send all the environment vars with '\0' delimitors...

First, we have to modify winpty_start_process
It's responsible to send the "start process" packet to the pipe.
It must not use a wchar_t* (because the putWString of the Buffer Class only send part before the first NULL)...
winpty.h

#include <string>
...
WINPTY_API int winpty_start_process(winpty_t *pc,
                                    const wchar_t *appname,
                                    const wchar_t *cmdline,
                                    const wchar_t *cwd,
                                    std::wstring env);

winpty.cc

WINPTY_API int winpty_start_process(winpty_t *pc,
                                    const wchar_t *appname,
                                    const wchar_t *cmdline,
                                    const wchar_t *cwd,
                                    std::wstring env)
{

    WriteBuffer packet;
    packet.putInt(AgentMsg::StartProcess);
    packet.putWString(appname ? appname : L"");
    packet.putWString(cmdline ? cmdline : L"");
    packet.putWString(cwd ? cwd : L"");
    packet.putWString(env);
    packet.putWString(getDesktopFullName());
    writePacket(pc, packet);
    return readInt32(pc);
}

Now the pty.cc
It calls winpty_start_process
It must create a std::wstring with all the vars separated by a NULL and finishing by 2*NULL:

static NAN_METHOD(PtyStartProcess) {
  NanScope();

  if (args.Length() != 5
    || !args[0]->IsNumber() // pid
    || !args[1]->IsString() // file
    || !args[2]->IsString() // cmdline
    || !args[3]->IsArray() // env
    || !args[4]->IsString()) // cwd
  {
    return NanThrowError(
        "Usage: pty.startProcess(pid, file, cmdline, env, cwd)");
  }

  // Get winpty_t by control pipe handle
  int pid = args[0]->Int32Value();

  winpty_t *pc = get_pipe_handle(pid);
  assert(pc != nullptr);

  const wchar_t *file = to_wstring(String::Utf8Value(args[1]->ToString()));
  const wchar_t *cmdline = to_wstring(String::Utf8Value(args[2]->ToString()));
  const wchar_t *cwd = to_wstring(String::Utf8Value(args[4]->ToString()));

  // create environment block
  std::wstring          env;
  const Handle<Array>   envValues       = Handle<Array>::Cast(args[3]);
  uint32_t              envValueCount   = envValues->Length();
  if (envValueCount > 0)
  {
      for(uint32_t i=0; i<envValueCount; i++)
      {
          env.append(to_wstring(String::Utf8Value(envValues->Get(i)->ToString())));
          env.push_back(L'\0');
      }
      env.push_back(L'\0');
  }

  /*
  wchar_t *env = NULL;
  const Handle<Array> envValues = Handle<Array>::Cast(args[3]);
  if(!envValues.IsEmpty()) {
      OutputDebugStringW(L"NOT EMPTY");
      if (envValues->Length() == 0) OutputDebugStringW(L"-> 0");
      if (envValues->Length() == 1) OutputDebugStringW(L"-> 1");
      if (envValues->Length() == 2) OutputDebugStringW(L"-> 2");

    std::wstringstream envBlock;

    for(uint32_t i = 0; i < envValues->Length(); i++) {
      std::wstring envValue(to_wstring(String::Utf8Value(envValues->Get(i)->ToString())));
      OutputDebugStringW(L"-----");
      OutputDebugStringW(envValue.c_str());
      envBlock << envValue << L' ';
    }

    std::wstring output = envBlock.str();

    size_t count = output.size();
    env = new wchar_t[count + 2];
    wcsncpy(env, output.c_str(), count);

    wcscat(env, L"\0");
  }
*/
  // Start new terminal
  int result = winpty_start_process(pc, file, cmdline, cwd, env);
  //delete env;

  assert(0 == result);

  NanReturnUndefined();
}

I hope this could help other people ;)
PS: sorry for my soooo bad English...

can't intall pyt.js

use npm install pyt.js
errors:

[email protected] install /tmp/sda/tty.js-master/node_modules/pty.js
node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: Command failed: Traceback (most recent call last):
gyp ERR! stack File "", line 1, in
gyp ERR! stack ImportError: No module named platform
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:637:15)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at maybeClose (child_process.js:735:16)
gyp ERR! stack at Socket. (child_process.js:948:11)
gyp ERR! stack at Socket.EventEmitter.emit (events.js:95:17)
gyp ERR! stack at Pipe.close (net.js:466:12)
gyp ERR! System Linux 3.3.8
gyp ERR! command "node" "/tmp/sda/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/sda/tty.js-master/node_modules/pty.js
gyp ERR! node -v v0.10.17
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! tar pack Error reading /tmp/sda/tmp/npm-25123-gHwCk0Bk/1389235978935-0.81437813 06307/package
npm ERR! addLocalDirectory Could not pack "/tmp/sda/tmp/npm-25123-gHwCk0Bk/1389235978935 8143781344406307/package" to "/tmp/sda/.npm/connect/2.11.0/package.tgz"

openpty()

I'm writing a chat server and I need pty for readline. But I dont want to fork anything, all connections should be processed by one process.

So... openpty and forkpty defined in the same files in C, would be nice to have both here.

100% CPU usage when pty stays on for long

I have created a pseudo bash Terminal which uses pty.js in the backend.

I am seeing that sometimes the server shoots to 100% CPU for one core & it stays there till the Node server is restarted.

It is a multi user setup & when a user connects pty spaws with 'su -l ' as the users need to be jailed into this directory. This 'su' command in some cases is creating 100% CPU usage which I am able to zero in on this issue pocha/terminal-codelearn#7 (comment)

Server - Ubuntu 12.04 64 bit AMD

npm version

{ http_parser: '1.0',
node: '0.10.17',
v8: '3.14.5.9',
ares: '1.9.0-DEV',
uv: '0.10.14',
zlib: '1.2.3',
modules: '11',
openssl: '1.0.1e',
npm: '1.3.8',
'terminal-codelearn': '0.0.3' }

MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0".

When running npm install pty.js on windows I get:

C:\cygwin\opts\newclient\node_modules\pty.js>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0".
gypnpm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the pty.js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls pty.js
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "pty.js"
npm ERR! cwd C:\cygwin\opts\newclient
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE

I have installed winpty, but apparently I'm missing some tools. What do I need more?

TypeError: Unsupported fd type: TTY

tip:

net.js:50
throw new TypeError('Unsupported fd type: ' + type);
^
TypeError: Unsupported fd type: TTY

in pty.js:66:17

My System ArchLinux x86_64
nodejs version 0.10.1 or 0.10.0

Disable stdin echo

When using pty.js the exec command (fork, spawn, and so on..) shows the echo of the input by stdout by default. If you are working with interactive applications it is very useful disable this echo.

We have corrected this issue adding this code in the file pty.cc in the line 178 (approximately).

/* Ensure that terminal echo is switched off so that we
   do not get back from the spawned process the same
   messages that we have sent it. */
struct termios orig_termios;
if (tcgetattr (STDIN_FILENO, &orig_termios) < 0) {
  perror ("ERROR getting current terminal's attributes");
  _exit(1);
}

orig_termios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
orig_termios.c_oflag &= ~(ONLCR);

if (tcsetattr (STDIN_FILENO, TCSANOW, &orig_termios) < 0) {
  perror ("ERROR setting current terminal's attributes");
  _exit(1);
}

It would be very useful provide the disable echo as a configuration option.

Thank you so much for making your pty software available.

build error on windows

hi i am getting this build error on windows
MSBUILD : error MSB6006: "VCBuild.exe" exited with code -1. [C:\projects\nodemirror\test\node_modules\pty.js\build\binding.sln]
MSBUILD : error MSB6006: "VCBuild.exe" exited with code -1. [C:\projects\nodemirror\test\node_modules\pty.js\build\binding.sln]

i used to have vs2008 and vs2010 installed but now only vs2012 is installed
i still get the error

i primarily developing for unix so this is strange to me
any help? maybe its a bug?

btw its a 64bit os

on a new system pty is giving `read EIO Use` error and crashing the node process

The new system is Ubuntu running in chroot on Chrome OS so it could be a dependency issue. I am running code that has been in production on EC2 Ubuntu boxes for several months without problems.

That said from what I have ready this error isn't an error and just means the the process has closed its output stream. The problem seems to be the pty.js is interpreting this as an error and then crashing because the stream is closed.

include binaries for windows version

as i tested successfully in nodeMirror, delivering binaries for windows is possible in npm.
so i request the feature that windows binaries are available by default.

pty.js requires pty.node from the wrong directory

I just installed 0.1.2 on

OSX 10.8.2
Node.js 0.8.12
npm 1.1.63
xcode 4.5.2 (in case it's something to do with the c++ compiler)

The build created a build/Release directory. However pty.js references build/default. This was simple to fix by changing the name of the directory in my node_modules (and this now works awesome for me - thanks!)

npm http GET https://registry.npmjs.org/pty.js-dl
npm http 304 https://registry.npmjs.org/pty.js-dl

> [email protected] install /Users/pghalliday/Development/Github/EstimationGame/node_modules/pty.js-dl
> node-gyp rebuild

  CXX(target) Release/obj.target/pty/src/pty.o
../src/pty.cc:61:17: warning: using directive refers to implicitly-defined
      namespace 'std'
using namespace std;
                ^
1 warning generated.
  SOLINK_MODULE(target) Release/pty.node
  SOLINK_MODULE(target) Release/pty.node: Finished
[email protected] node_modules/pty.js-dl

Windows Power Shell

If I fork Power Shell on windows it throws this error:

F:\Programare\Node.JS\derby-0.6\saron-daemon>coffee test.coffee

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS F:\Programare\Node.JS\derby-0.6\saron-daemon\node_modules\saron-daemon-termin
al>

al> Internal Windows PowerShell error.  Loading managed Windows PowerShell faile

d with error 8009001d.

Terminal exited.

I have this code in test.coffee

pty = require('pty.js')

term = pty.fork 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', [],
  name: 'Windows Shell'
  cols: 80
  rows: 25
  cwd: process.env.HOME
  env: process.env

term.on 'data', (data) ->
  console.log data

term.on 'exit', () ->
  console.log "Terminal exited."

Mac OS X 10.6.8 loses connection?

I'm attempting to use this library on Mac OS X 10.6.8 with node 0.6.15.

When I run the following test case:

var term = pty.spawn('tail', ['-f','/var/log/system.log'], {
  name: 'xterm-color',
  cols: 80,
  rows: 30,
  cwd: process.env.HOME,
  env: process.env
});
// logs first set of data, but never fires again.
term.on('data', function(data) {
  console.log(data);
});
// does not run
term.on('exit', function() { console.log('exited') });

The console prints out 1024 bytes of data and then stops updating (the provided example with ls also fails. I can see 'ls' get written, but get no response from the terminal). The process continues to run, but pty.js does not get any updates. The same code on Mac OS X 10.7.2 runs without issue.

Any ideas? Thanks!

stdin of child never see's EOF

Here's a node script to reproduce (both child and master are in the same file, like the node core fork tests):

if (process.argv[2] === 'child') {
  // child
  process.stdin.resume();
  process.stdin.on('end', function () {
    console.error('got end!')
  });
} else {
  // main process
  var pty = require('./')
  var child = pty.spawn(process.execPath, [ __filename, 'child' ]);
  child.pipe(process.stdout);
  setTimeout(function () {
    child.end();
  }, 500);
  child.on('exit', function () {
    clearTimeout(timeout);
  });
  var timeout = setTimeout(function () {
    throw new Error('timeout!');
  }, 3000);
}

This fails on all OS's I've tried, that is, the child "end" event never fires, and the child remains alive forever until the script times out and fails.

How To Scale

@chjj thanks for building pty.js and term.js, it is amazing! I am using it for a site where users can open up a terminal session in the browser. What is the best way to scale pty.js when you have multiple servers and a load balancer?

Support for args

Ideally the signature would be as follows

new Terminal('bash', [args], { options })

PATH variable is null on windows

I get this in terminal in browser:

F:\Programare\Node.JS\derby-0.6\saron-daemon>PATH                               
PATH=(null) 

Is there a way to have PATH variable the same as on PC?

Because PATH is null, I have to start all applications with absolute path like:

F:\Programare\Node.JS\derby-0.6\saron-daemon>C:\Python27\python.exe             
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win
32                                                                              
Type "help", "copyright", "credits" or "license" for more information.          
>>>

Does not build on windows

I've got a Windows NT system that I cannot build pty.js on. Is there instructions on how to do this?

My system is setup with the following:

MS Visual Studio 2010 SP1 Premium edition
Node v0.6.15 (used MSI installer)
Python 2.7.2 (used MSI installer)
MinGW (used MSI installer)
PYTHON=c:\python27\python.exe
NODE_PATH=C:\Progra~2\nodejs\node.exe

I've installed node-gyp via npm install -g node-gyp.

I've added pty.js to my package.json file and I can see it trying to build when I run npm install -d. I've tried the install command in a standard command prompt, a visual studio command prompt, and a mingw command prompt.

-- Command output --

C:\V2Source\trunk\product\applications\UcpPostDeploy\server>npm install -d
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info preinstall [email protected]
npm http GET https://registry.npmjs.org/pty.js
npm http 304 https://registry.npmjs.org/pty.js
npm info into C:\V2Source\trunk\product\applications\UcpPostDeploy\server [email protected]
npm info installOne [email protected]
npm info unbuild C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js
npm info preinstall [email protected]
npm info build C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js
npm info linkStuff [email protected]
npm info install [email protected]

> [email protected] install C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js
> node-gyp rebuild


C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js>node "C:\Program Files     (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\
\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
info it worked if it ends with ok
spawn C:\Python27\python.exe [ 'C:\\Users\\jclark\\.node-gyp\\0.6.15\\tools\\gyp_addon',
  'binding.gyp',
  '-IC:\\V2Source\\trunk\\product\\applications\\UcpPostDeploy\\server\\node_modules\\pty.js\\build\\config.gypi',
  '-f',
  'msvs',
  '-G',
      'msvs_version=2010' ]
spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe [ 'build/binding.sln',
  '/clp:Verbosity=minimal',
  '/nologo',
  '/p:Configuration=Release;Platform=Win32' ]
  pty.cc
C:\Users\jclark\.node-gyp\0.6.15\src\node_object_wrap.h(57): warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persistent<T>' needs to have dll
-interface to be used by clients of class 'node::ObjectWrap' [C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js\build\p
ty.vcxproj]
          with
          [
              T=v8::Object
          ]
..\src\pty.cc(20): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory [C:\V2Source\trunk\product\applications\UcpPost
Deploy\server\node_modules\pty.js\build\pty.vcxproj]
ERR! Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
    at Array.0 (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:176:25)
    at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok
npm info [email protected] Failed to exec install script
npm info unbuild C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info postuninstall [email protected]

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `cmd "/c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the pty.js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls pty.js
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-d"
npm ERR! cwd C:\V2Source\trunk\product\applications\UcpPostDeploy\server
npm ERR! node -v v0.6.15
npm ERR! npm -v 1.1.16
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: `node-gyp rebuild`
npm ERR! message `cmd "/c" "node-gyp rebuild"` failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\V2Source\trunk\product\applications\UcpPostDeploy\server\npm-debug.log
npm not ok

-- NPM-debug.log --

info it worked if it ends with ok
verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe',
verbose cli   'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
verbose cli   'install',
verbose cli   '-d' ]
info using [email protected]
info using [email protected]
verbose C:\Program Files (x86)\nodejs\\node.exe node symlink
verbose config file C:\Users\jclark\.npmrc
verbose config file C:\Program Files (x86)\nodejs\etc\npmrc
verbose config file C:\Program Files (x86)\nodejs\node_modules\npm\npmrc
verbose caching C:\V2Source\trunk\product\applications\UcpPostDeploy\server\package.json
verbose loadDefaults [email protected]
verbose readDependencies: using package.json deps
verbose where, deps [ 'C:\\V2Source\\trunk\\product\\applications\\UcpPostDeploy\\server',
verbose where, deps   [ 'express', 'ejs', 'underscore', 'pty.js' ] ]
verbose from cache C:\V2Source\trunk\product\applications\UcpPostDeploy\server\package.json
info preinstall [email protected]
verbose caching C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\ejs\package.json
verbose caching C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\express\package.json
verbose caching C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\underscore\package.json
verbose from cache C:\V2Source\trunk\product\applications\UcpPostDeploy\server\package.json
verbose readDependencies: using package.json deps
verbose from cache C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\ejs\package.json
verbose from cache C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\express\package.json
verbose from cache C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\underscore\package.json
verbose already installed in C:\V2Source\trunk\product\applications\UcpPostDeploy\server skipping ejs@>= 0.0.1
verbose already installed in C:\V2Source\trunk\product\applications\UcpPostDeploy\server skipping underscore@>= 1.3.0
verbose cache add [ 'pty.js@>= 0.1.1', null ]
silly cache add: name, spec, args [ undefined, 'pty.js@>= 0.1.1', [ 'pty.js@>= 0.1.1', null ] ]
verbose parsed url { pathname: 'pty.js@', path: 'pty.js@', href: 'pty.js@' }
silly cache add: name, spec, args [ 'pty.js', '>= 0.1.1', [ 'pty.js', '>= 0.1.1' ] ]
verbose parsed url { pathname: '=', path: '=', href: '=' }
verbose addNamed [ 'pty.js', '>= 0.1.1' ]
verbose addNamed [ null, '>=0.1.1' ]
silly name, range, hasData [ 'pty.js', '>=0.1.1', false ]
verbose already installed in C:\V2Source\trunk\product\applications\UcpPostDeploy\server skipping [email protected]
verbose raw, before any munging pty.js
verbose url resolving [ 'https://registry.npmjs.org/', './pty.js' ]
verbose url resolved https://registry.npmjs.org/pty.js
verbose etag "C8UZ4QS2T14IVWKZN8LJ583A5"
http GET https://registry.npmjs.org/pty.js
http 304 https://registry.npmjs.org/pty.js
silly get cb [ 304,
silly get cb   { server: 'CouchDB/1.2.0 (Erlang OTP/R15B)',
silly get cb     etag: '"C8UZ4QS2T14IVWKZN8LJ583A5"',
silly get cb     date: 'Thu, 03 May 2012 22:29:46 GMT',
silly get cb     'content-length': '0' } ]
verbose etag pty.js from cache
silly name, range, hasData 2 [ 'pty.js', '>=0.1.1', true ]
silly versions [ 'pty.js',
silly versions   [ '0.0.1',
silly versions     '0.0.2',
silly versions     '0.0.3',
silly versions     '0.0.4',
silly versions     '0.0.5',
silly versions     '0.0.6',
silly versions     '0.0.6-1',
silly versions     '0.0.7',
silly versions     '0.0.8',
silly versions     '0.0.9',
silly versions     '0.1.0',
silly versions     '0.1.1' ] ]
verbose bin dist [ '0.6-ares1.7.5-DEV-evundefined-openssl0.9.8r-v83.6.6.24-win32-ia32-6.1.7601',
verbose bin dist   { shasum: '8c91b44d6b3767c71d61901b44633c8cac909beb',
verbose bin dist     tarball: 'http://registry.npmjs.org/pty.js/-/pty.js-0.1.1.tgz' } ]
verbose has bindings.gyp [ undefined,
verbose has bindings.gyp   { file: 'C:\\Users\\jclark\\AppData\\Roaming\\npm-cache\\pty.js\\0.1.1\\package\\package.json',
verbose has bindings.gyp     gypfile: true,
verbose has bindings.gyp     contributors: false,
verbose has bindings.gyp     serverjs: false,
verbose has bindings.gyp     wscript: true } ]
verbose has wscript [ undefined,
verbose has wscript   { file: 'C:\\Users\\jclark\\AppData\\Roaming\\npm-cache\\pty.js\\0.1.1\\package\\package.json',
verbose has wscript     gypfile: true,
verbose has wscript     contributors: false,
verbose has wscript     serverjs: false,
verbose has wscript     wscript: true } ]
verbose caching C:\Users\jclark\AppData\Roaming\npm-cache\pty.js\0.1.1\package\package.json
verbose loadDefaults [email protected]
silly resolved [ { name: 'pty.js',
silly resolved     description: 'Pseudo terminals for node.',
silly resolved     author: { name: 'Christopher Jeffrey' },
silly resolved     version: '0.1.1',
silly resolved     main: './index.js',
silly resolved     repository: { type: 'git', url: 'git://github.com/chjj/pty.js.git' },
silly resolved     homepage: 'https://github.com/chjj/pty.js',
silly resolved     bugs: { url: 'https://github.com/chjj/pty.js/issues' },
silly resolved     keywords: [ 'pty', 'tty', 'terminal' ],
silly resolved     scripts: { test: 'node test', install: 'node-gyp rebuild' },
silly resolved     tags: [ 'pty', 'tty', 'terminal' ],
silly resolved     _id: '[email protected]',
silly resolved     dependencies: {},
silly resolved     devDependencies: {},
silly resolved     optionalDependencies: {},
silly resolved     engines: { node: '*' },
silly resolved     _engineSupported: true,
silly resolved     _npmVersion: '1.1.16',
silly resolved     _nodeVersion: 'v0.6.15',
silly resolved     _defaultsLoaded: true,
silly resolved     _from: 'pty.js@>= 0.1.1' } ]
info into C:\V2Source\trunk\product\applications\UcpPostDeploy\server [email protected]
info installOne [email protected]
verbose from cache C:\Users\jclark\AppData\Roaming\npm-cache\pty.js\0.1.1\package\package.json
info unbuild C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js
verbose unpack C:\Users\jclark\AppData\Roaming\npm-cache\pty.js\0.1.1\package.tgz
silly gunzTarPerm modes [ '755', '644' ]
silly extracting entry package.json
silly modified mode [ 'package.json', 438, 420 ]
silly extracting entry .npmignore
silly modified mode [ '.npmignore', 438, 420 ]
silly extracting entry README.md
silly modified mode [ 'README.md', 438, 420 ]
silly extracting entry LICENSE
silly modified mode [ 'LICENSE', 438, 420 ]
silly extracting entry index.js
silly modified mode [ 'index.js', 438, 420 ]
silly extracting entry binding.gyp
silly modified mode [ 'binding.gyp', 438, 420 ]
silly extracting entry lib/pty.js
silly modified mode [ 'lib/pty.js', 438, 420 ]
silly extracting entry Makefile
silly modified mode [ 'Makefile', 438, 420 ]
silly extracting entry src/pty.cc
silly modified mode [ 'src/pty.cc', 438, 420 ]
silly extracting entry wscript
silly modified mode [ 'wscript', 438, 420 ]
verbose has bindings.gyp [ undefined,
verbose has bindings.gyp   { file: 'C:\\V2Source\\trunk\\product\\applications\\UcpPostDeploy\\server\\node_modules\\pty.js\\package.json',
verbose has bindings.gyp     gypfile: true,
verbose has bindings.gyp     contributors: false,
verbose has bindings.gyp     serverjs: false,
verbose has bindings.gyp     wscript: true } ]
verbose has wscript [ undefined,
verbose has wscript   { file: 'C:\\V2Source\\trunk\\product\\applications\\UcpPostDeploy\\server\\node_modules\\pty.js\\package.json',
verbose has wscript     gypfile: true,
verbose has wscript     contributors: false,
verbose has wscript     serverjs: false,
verbose has wscript     wscript: true } ]
verbose caching C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js\package.json
verbose loadDefaults [email protected]
info preinstall [email protected]
verbose from cache C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js\package.json
verbose readDependencies: using package.json deps
verbose from cache C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js\package.json
verbose readDependencies: using package.json deps
silly resolved []
verbose about to build C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js
info build C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js
verbose from cache C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js\package.json
verbose linkStuff [ false,
verbose linkStuff   false,
verbose linkStuff   false,
verbose linkStuff   'C:\\V2Source\\trunk\\product\\applications\\UcpPostDeploy\\server\\node_modules' ]
info linkStuff [email protected]
verbose linkBins [email protected]
verbose linkMans [email protected]
verbose rebuildBundles [email protected]
info install [email protected]
verbose unsafe-perm in lifecycle true
silly exec cmd "/c" "node-gyp rebuild"
silly spawning [ 'cmd',
silly spawning   [ '/c', 'node-gyp rebuild' ],
silly spawning   'C:\\V2Source\\trunk\\product\\applications\\UcpPostDeploy\\server\\node_modules\\pty.js' ]
info [email protected] Failed to exec install script
info unbuild C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js
verbose from cache C:\V2Source\trunk\product\applications\UcpPostDeploy\server\node_modules\pty.js\package.json
info preuninstall [email protected]
info uninstall [email protected]
verbose unbuild [email protected] [ true,
verbose unbuild [email protected]   'C:\\V2Source\\trunk\\product\\applications\\UcpPostDeploy\\server\\node_modules',
verbose unbuild [email protected]   'C:\\V2Source\\trunk\\product\\applications\\UcpPostDeploy\\server\\node_modules' ]
info postuninstall [email protected]
ERR! [email protected] install: `node-gyp rebuild`
ERR! `cmd "/c" "node-gyp rebuild"` failed with 1
ERR! 
ERR! Failed at the [email protected] install script.
ERR! This is most likely a problem with the pty.js package,
ERR! not with npm itself.
ERR! Tell the author that this fails on your system:
ERR!     node-gyp rebuild
ERR! You can get their info via:
ERR!     npm owner ls pty.js
ERR! There is likely additional logging output above.
ERR! 
ERR! System Windows_NT 6.1.7601
ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-d"
ERR! cwd C:\V2Source\trunk\product\applications\UcpPostDeploy\server
ERR! node -v v0.6.15
ERR! npm -v 1.1.16
ERR! code ELIFECYCLE
ERR! message [email protected] install: `node-gyp rebuild`
ERR! message `cmd "/c" "node-gyp rebuild"` failed with 1
ERR! errno {}
verbose exit [ 1, true ]

Does not compile on Solaris

make: Entering directory `/home/node/codestre.am-cli/node_modules/pty.js/build'
  CXX(target) Release/obj.target/pty/src/pty.o
../src/pty.cc:36:17: warning: pty.h: No such file or directory
../src/pty.cc: In function `v8::Handle<v8::Value> PtyFork(const v8::Arguments&)':
../src/pty.cc:168: error: `forkpty' was not declared in this scope
../src/pty.cc:168: warning: unused variable 'forkpty'
../src/pty.cc: In function `v8::Handle<v8::Value> PtyOpen(const v8::Arguments&)':
../src/pty.cc:235: error: `openpty' was not declared in this scope
../src/pty.cc:235: warning: unused variable 'openpty'
make: *** [Release/obj.target/pty/src/pty.o] Error 1
make: Leaving directory `/home/node/codestre.am-cli/node_modules/pty.js/build'
ERR! Error: `make` failed with exit code: 2
    at Array.0 (/home/node/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:169:25)
    at EventEmitter._tickCallback (node.js:238:41)
ERR! not ok

After a quick google search it appears this functionality (openpty, forkpty) has to be ported over to Unixes that don't have native support for it.

Failed to install pty.js

I got the following error message:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
sh: node-gyp: command not found

My node-gyp is actually installed. Can anybody help? Thanks

force redraw

is there a way to force a redraw of the terminal?

i can reopen a running terminal after reloading the page. but it remains empty until i force a resize. i would like to force a redraw instead.

can not install on MACOSX with node- 0.11.11

I am seeing the following issue when trying to install pty.js-11 on mac with node 0.11.11
where is wait.h supposed to come from?

Darwin 13.0.2 Darwin Kernel Version 13.0.2: Sun Sep 29 19:38:57 PDT 2013; root:xnu-2422.75.4~1/RELEASE_X86_64 x86_64
dockworker$ npm install pty.js-11
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/pty.js-11
npm http 304 https://registry.npmjs.org/pty.js-11
npm http GET https://registry.npmjs.org/nan/0.7.0
npm http GET https://registry.npmjs.org/extend
npm http 304 https://registry.npmjs.org/nan/0.7.0
npm http 304 https://registry.npmjs.org/extend

> [email protected] install /Users/anand/run/dockworker/node_modules/pty.js-11
> node-gyp rebuild

  CXX(target) Release/obj.target/pty/src/unix/pty.o
../src/unix/pty.cc:220:10: fatal error: 'wait.h' file not found
#include <wait.h>
         ^
1 error generated.
make: *** [Release/obj.target/pty/src/unix/pty.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:107:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:879:12)
gyp ERR! System Darwin 13.0.2
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/anand/run/dockworker/node_modules/pty.js-11
gyp ERR! node -v v0.11.11
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the pty.js-11 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls pty.js-11
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.0.2
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "pty.js-11"
npm ERR! cwd /Users/anand/run/dockworker
npm ERR! node -v v0.11.11
npm ERR! npm -v 1.3.25
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/anand/run/dockworker/npm-debug.log
npm ERR! not ok code 0
dockworker$ cat /Users/anand/run/dockworker/npm-debug.log

exit code

pty.js does not forward the exit code:

this.socket.on('close', function() {
  Terminal.total--;
  self._close();
  self.emit('exit', null);
});

But I really don't know how to do this...

stderr?

Excuse my ignorance if there is an obvious reason for this but why does trying to get the output from stderr like so:

child.stderr.on('data', function(data) {});

result in https://github.com/chjj/pty.js/blob/master/lib/pty.js#L289

Is it simply not possible to get the output from stderr or has it just not been implemented?

Thanks :)

zombie process either by process.kill or pty.destroy

This is the same problem as seen in #8 (which is closed).

The following spawns a bash shell every 3 seconds, and destroys each one after 500ms. It leaves behind a bunch of zombie processes.

PTY = require("pty.js")

console.log "Process: #{process.pid}"

bash = ->
  pty = PTY.spawn("bash",[],{
    name: 'xterm-color'
    cwd: process.cwd()
    env: process.env
  })

  setTimeout (->
    console.log "kill", pty.pid
    # Both of the following leave zombie processes
    # process.kill(pty.pid,"SIGTERM")
    # process.kill(pty.pid,"SIGHUP")
    pty.destroy()
  ), 500

setInterval (-> bash()), 3000

issue with cluster module on windows

this code will not run in windows:

var cluster = require("cluster");

if (cluster.isMaster) {
  cluster.fork();
  setTimeout(function () {
    console.log("ending master");
  }, 2000);
  return;
};

var pty;

if (process.platform == "win32") {
  pty = require("./pty-win/index.js");
} else {
  pty = require("pty.js");
};

var term;

if (process.platform == "win32") {
  // use fork instead
  term = pty.fork("cmd.exe", [], {
    name: 'cmd',
    cols: 80,
    rows: 30,
    cwd: process.env.HOME,
    env: process.env
  });
} else {
  term = pty.spawn("bash", [], {
    name: 'xterm-color',
    cols: 80,
    rows: 30,
    cwd: process.env.HOME,
    env: process.env
  });
};

term.on("data", function (data) {
  console.log(data);
});

term.write("dir\r\n");

appears broken for node v0.8.9

Seeing the following error when attempting to run the example ( or any other binary ) on node 0.8.9 on Mac 10.6.7

bash
Assertion failed: (!!(events & UV__IO_READ) ^ !!(events & UV__IO_WRITE)), function uv__stream_io, file ../deps/uv/src/unix/stream.c, line 732.
Abort trap

Reinstalled node to be sure, still seeing same issue. Unsure what the problem is.

Solaris: pty_openpty() call to set the size fails with EINVAL

So it looks like the initial call to set the size fails on solaris with EINVAL (22).

As a hack workaround, I fixed it in JS-land:

diff --git a/lib/pty.js b/lib/pty.js
index b6a1efa..ac6f763 100644
--- a/lib/pty.js
+++ b/lib/pty.js
@@ -60,6 +60,10 @@ function Terminal(file, args, opt) {

   // fork
   term = pty.fork(file, args, env, cwd, cols, rows);
+
+  // XXX: solaris hack...
+  pty.resize(term.fd, cols, rows);
+
   this.socket = new net.Socket(term.fd);
   this.socket.setEncoding('utf8');
   this.socket.resume();

But I assume there's probably a cleaner fix in C-land.

documentation gives incorrect require line

Just installed 0.1.2 on node 0.8.12 and found that I had to require like this:

var pty = require('pty.js-dl');

and not

var pty = require('pty.js');

as described in the readme

Kernel Panic on OSX

I'm using OSX 10.7.5. I tried both the NPM version and the latest master (26th of April).

I'm getting highly reproducible Kernel Panics. This wouldn't be a big issue, except that we're trying to release a version of Cloud9 IDE that runs on OSX.

I've listed the Kernel Panic logs here: https://gist.github.com/javruben/5472500

Here's a small app that will crash:

 var pty = require("pty.js");

 function go(){
      var proc = pty.spawn("nothing", [], { cwd: "~" });
      proc.on("error", function(err){ console.log(err); }
      proc.on("data", function(data){ console.log(data); }
      proc.on("exit", function(data){
           go();
      });
 }

 go();

I noticed that when the data event is not set, it doesn't seem to crash. I didn't thoroughly test that,so I'm not sure if that is absolutely true.

It would be awesome if you could help getting this fixed.

npm install error

errors is:

[email protected] install /tmp/sda/tty.js-master/node_modules/pty.js
node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | mips
gyp ERR! configure error
gyp ERR! stack Error: Command failed: Traceback (most recent call last):
gyp ERR! stack File "", line 1, in
gyp ERR! stack ImportError: No module named platform
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:637:15)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at maybeClose (child_process.js:735:16)
gyp ERR! stack at Socket. (child_process.js:948:11)
gyp ERR! stack at Socket.EventEmitter.emit (events.js:95:17)
gyp ERR! stack at Pipe.close (net.js:466:12)
gyp ERR! System Linux 3.3.8
gyp ERR! command "node" "/tmp/sda/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/sda/tty.js-master/node_modules/pty.js
gyp ERR! node -v v0.10.17
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm info [email protected] Failed to exec install script
npm info /tmp/sda/tty.js-master/node_modules/pty.js unbuild
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info postuninstall [email protected]
npm ERR! weird error 1
npm ERR! not ok code 0

pty.js uses 100% CPU when tmux session gets detached

I'm using pty.js in combination with tmux sessions in order to have persistent terminal sessions. Unfortunately it often gets into a state where it uses 100% CPU. I made a minimal proof of concept that easily reproduces it:

var pty = require("pty.js");

function spawn(command) {
    console.log(command);
    var term = pty.spawn("bash", ["-l", "-c", command]);

    term.on("error", function(e) {
        console.error(JSON.stringify(e));
    });
    term.on("close", function(e) {
        console.log("close", e)
    });
}

// (1) Create/reuse a tmux session
spawn("tmux new -A -s test");
setTimeout(function() {
    // (2) Attach to session; detach other clients
    spawn("tmux attach -t test -d");

    console.log("Done.");
}, 3000);

This does two things: (1) create a new tmux session using pty.js; and (2) attach to that session, detaching all existing clients. So (2) will detach the session from (1).

Assuming tmux is installed, the program above prints

tmux new -A -s test
tmux attach -t test -d
Done.
{"code":"EIO","errno":"EIO","syscall":"read"}
close true

and then starts using 100% CPU

I can reproduce this with tmux 1.8 on Ubuntu, built using c9/install's install.sh install tmux_install. But it seems likely that this is a very general issue in pty.js.

do terminals have titles?

terminal windows in unix and sometimes even in windows seem to have a title. is there any way to access the title string in pty.js?

can't install on windows

when I git clone this repo, then run the command : npm install,
I got this in npm-debug.log

help!

0 info it worked if it ends with ok
1 verbose cli [ 'D:\Program Files\nodejs\node.exe',
1 verbose cli 'D:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'install' ]
2 info using [email protected]
3 info using [email protected]
4 verbose node symlink D:\Program Files\nodejs\node.exe
5 verbose read json C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master\package.json
6 verbose readDependencies using package.json deps
7 verbose install where, deps [ 'C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master',
7 verbose install [ 'extend', 'mocha' ] ]
8 verbose from cache C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master\package.json
9 info preinstall [email protected]
10 verbose read json C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master\node_modules\extend\package.json
11 verbose read json C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master\node_modules\mocha\package.json
12 verbose from cache C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master\package.json
13 verbose readDependencies using package.json deps
14 verbose from cache C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master\node_modules\extend\package.json
15 verbose from cache C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master\node_modules\mocha\package.json
16 verbose already installed skipping extend@~1.2.1 C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master
17 verbose already installed skipping mocha@~1.7.1 C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master
18 silly resolved []
19 info build C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master
20 verbose from cache C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master\package.json
21 verbose linkStuff [ false,
21 verbose linkStuff false,
21 verbose linkStuff false,
21 verbose linkStuff 'C:\Users\Administrator\Documents\GitHub\goorm\libs\core' ]
22 info linkStuff [email protected]
23 verbose linkBins [email protected]
24 verbose linkMans [email protected]
25 verbose rebuildBundles [email protected]
26 verbose rebuildBundles [ '.bin', 'extend', 'mocha' ]
27 info install [email protected]
28 verbose unsafe-perm in lifecycle true
29 silly exec cmd "/c" "node-gyp rebuild"
30 silly cmd,/c,node-gyp rebuild,C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master spawning
31 info [email protected] Failed to exec install script
32 error [email protected] install: node-gyp rebuild
32 error cmd "/c" "node-gyp rebuild" failed with 1
33 error Failed at the [email protected] install script.
33 error This is most likely a problem with the pty.js package,
33 error not with npm itself.
33 error Tell the author that this fails on your system:
33 error node-gyp rebuild
33 error You can get their info via:
33 error npm owner ls pty.js
33 error There is likely additional logging output above.
34 error System Windows_NT 6.1.7600
35 error command "D:\Program Files\nodejs\node.exe" "D:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
36 error cwd C:\Users\Administrator\Documents\GitHub\goorm\libs\core\pty.js-master
37 error node -v v0.10.6
38 error npm -v 1.2.18
39 error code ELIFECYCLE
40 verbose exit [ 1, true ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.