changeset 2:98bf7c94c954

webtty.js: set up the environment and working directory.
author John "Elwin" Edwards <elwin@sdf.org>
date Sun, 06 May 2012 15:06:32 -0700
parents 9bef0941c6dd
children bfdc775a574f
files webtty.js
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/webtty.js	Sun May 06 09:04:14 2012 -0700
+++ b/webtty.js	Sun May 06 15:06:32 2012 -0700
@@ -7,14 +7,24 @@
 var child_process = require("child_process");
 
 var serveStaticRoot = "/home/elwin/hk/nodejs/rlg/s/";
+var ptyhelp = "/home/elwin/hk/nodejs/rlg/ptywreck/ptyhelperC";
 var sessions = {};
 
+var env_dontuse = {"TMUX": true, "TMUX_PANE": true};
+
 /* Constructor for TermSessions.  Note that it opens the terminal and 
  * adds itself to the sessions dict. 
  */
 function TermSession(sessid) {
+  var childenv = {};
+  for (var key in process.env) {
+    if (!(key in env_dontuse))
+      childenv[key] = process.env[key];
+  }
+  // Should setsid get set?
+  var spawnopts = {"env": childenv, "cwd": process.env["HOME"]};
   //var pterm = tty.open("/bin/bash");
-  this.child = child_process.spawn("./ptywreck/ptyhelperC", ["bash"]);
+  this.child = child_process.spawn(ptyhelp, ["bash"], spawnopts);
   var ss = this;
   /* Eventually we'll need to make sure the sessid isn't in use yet. */
   this.sessid = sessid;