You need to do something like: process.kill(child.pid, 'SIGINT');
On Fri, Jul 27, 2012 at 4:57 PM, Herry Wang <[email protected]> wrote: > yeah, actually i am looking into tty.js. But i wanna use it in my own > project with 'light' version. > Just wandering why \x03 is not working. > > Thanks > Herry > > > On Fri, Jul 27, 2012 at 4:49 PM, Marak Squires <[email protected]>wrote: > >> I would say try: https://github.com/chjj/tty.js >> >> On Fri, Jul 27, 2012 at 4:47 PM, Herry Wang <[email protected]> wrote: >> >>> I am writing one web-like linux shell using node.js + socket.io. Simple >>> command like, ls, cd are working well. But when issue command like ping >>> google.com, the stdout is printing endlessly. I tried to send Ctrl +C >>> to stdin, but no luck. >>> >>> 1) spawn 'bash' process >>> >>> spawn = require('child_process').spawn; >>> >>> >>> >>> var sh = spawn('bash'); >>> >>> >>> >>> 2) send bash stdout to socket.io >>> >>> sh.stdout.on('data', function(data) { >>> >>> >>> >>> >>> console.log('stdout' + data); >>> >>> >>> >>> >>> listener.sockets.emit("stdout",new Buffer(data)); >>> >>> >>> >>> }); >>> >>> >>> >>> 3) Sending Ctl C (\x03) to bash's stdin. var listener = >>> io.listen(server); >>> >>> listener.set('log level',1); >>> >>> >>> >>> >>> listener.sockets.on('connection', function(client){ >>> >>> >>> >>> >>> client.on('message', function(data){ >>> >>> >>> >>> >>> if(data === "KILL") { >>> >>> >>> >>> >>> console.log('!!!!' + data); >>> >>> >>> >>> >>> sh.stdin.write('\x03'); >>> >>> >>> >>> >>> client.broadcast.send(new Buffer("KILLING ")); >>> >>> >>> >>> >>> //return; >>> >>> >>> >>> >>> }; >>> >>> >>> >>> >>> console.log(data); >>> >>> >>> >>> >>> sh.stdin.write(data+"\n"); >>> >>> >>> >>> >>> client.broadcast.send(new Buffer("> "+data)); >>> >>> >>> >>> >>> }); >>> >>> >>> >>> }); >>> >>> >>> >>> I am stuck at this point. Seems like >>> >>> -- >>> Job Board: http://jobs.nodejs.org/ >>> Posting guidelines: >>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To post to this group, send email to [email protected] >>> To unsubscribe from this group, send email to >>> [email protected] >>> For more options, visit this group at >>> http://groups.google.com/group/nodejs?hl=en?hl=en >>> >> >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> You received this message because you are subscribed to the Google >> Groups "nodejs" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en >> > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
