steelbrain/node-ssh

Close Command Execution Not Working

dudu631 opened this issue · 2 comments

Hi,

I'm running a command using execCommand method. Also I'm passing a onChannel ( clientChannel: ClientChannel) option as parameter to get client channel connection.

My issue is that I can't by any mean stop the command execution (simulating a CTRL-C during an execution).

I've tried:

clientChannel.close()
clientChannel.end()
clientChannel.write('\x03')
clientChannel.signal('INT')

To test this out, I run a command with execCommand then I close it, and after I check my running processes on my server it's still running there. I have to mannually kill them with kill {pid}.

What am I missing?

One thing I just found out:

The command I'm using invokes an executable file.
Example:
./executable arg1 arg2

A command without an executable file like ping, the close option works.

Is there a way to kill the process of a executable file command, without grep and kill?

Currently using a workaround:

Passing execOptions: { pty: true } to execCommand params seems to make clientChannel.close() work.

Hoping to listen to more ideas on this.