comparison webtty.js @ 3:bfdc775a574f

webtty.js: remove tty-module code.
author John "Elwin" Edwards <elwin@sdf.org>
date Sun, 06 May 2012 15:22:13 -0700
parents 98bf7c94c954
children d1b3c3af34d6
comparison
equal deleted inserted replaced
2:98bf7c94c954 3:bfdc775a574f
1 #!/usr/bin/env node 1 #!/usr/bin/env node
2 var http = require('http'); 2 var http = require('http');
3 var url = require('url'); 3 var url = require('url');
4 var path = require('path'); 4 var path = require('path');
5 var fs = require('fs'); 5 var fs = require('fs');
6 //var tty = require("tty");
7 var child_process = require("child_process"); 6 var child_process = require("child_process");
8 7
9 var serveStaticRoot = "/home/elwin/hk/nodejs/rlg/s/"; 8 var serveStaticRoot = "/home/elwin/hk/nodejs/rlg/s/";
10 var ptyhelp = "/home/elwin/hk/nodejs/rlg/ptywreck/ptyhelperC"; 9 var ptyhelp = "/home/elwin/hk/nodejs/rlg/ptywreck/ptyhelperC";
11 var sessions = {}; 10 var sessions = {};
21 if (!(key in env_dontuse)) 20 if (!(key in env_dontuse))
22 childenv[key] = process.env[key]; 21 childenv[key] = process.env[key];
23 } 22 }
24 // Should setsid get set? 23 // Should setsid get set?
25 var spawnopts = {"env": childenv, "cwd": process.env["HOME"]}; 24 var spawnopts = {"env": childenv, "cwd": process.env["HOME"]};
26 //var pterm = tty.open("/bin/bash");
27 this.child = child_process.spawn(ptyhelp, ["bash"], spawnopts); 25 this.child = child_process.spawn(ptyhelp, ["bash"], spawnopts);
28 var ss = this; 26 var ss = this;
29 /* Eventually we'll need to make sure the sessid isn't in use yet. */ 27 /* Eventually we'll need to make sure the sessid isn't in use yet. */
30 this.sessid = sessid; 28 this.sessid = sessid;
31 //this.ptmx = pterm[0];
32 //this.child = pterm[1];
33 this.alive = true; 29 this.alive = true;
34 this.data = []; 30 this.data = [];
35 this.child.stdout.on("data", function (buf) { 31 this.child.stdout.on("data", function (buf) {
36 ss.data.push(buf); 32 ss.data.push(buf);
37 }); 33 });
72 }; 68 };
73 this.cleanup = function () { 69 this.cleanup = function () {
74 /* Call this when the child is dead. */ 70 /* Call this when the child is dead. */
75 if (this.alive) 71 if (this.alive)
76 return; 72 return;
77 //ss.ptmx.destroy();
78 /* Give the client a chance to read any leftover data. */ 73 /* Give the client a chance to read any leftover data. */
79 if (ss.data.length > 0) 74 if (ss.data.length > 0)
80 setTimeout(ss.remove, 8000); 75 setTimeout(ss.remove, 8000);
81 else 76 else
82 ss.remove(); 77 ss.remove();