Skip to content
Advertisement

Kill process before disconnecting

I am using Jsch to tail a server-log. When I close my exec-channel and session, the “tail -f …” process still stays alive at server side.

I tried to do channel.sendSignal("KILL") but it throws an exception: com.jcraft.jsch.JSchException: failed to send channel request

how can I do a clean disconnect?

Advertisement

Answer

I know this is an old post but I’m posting my solution in case someone needs it.

After some testing I learned that I had to send the int value of the signal instead of the string:

JavaScript

For more signals scroll to ‘Standard signals’ on this page.

I’m using the following methods to send and interrupt commands. They are slightly modified versions of the example found here.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement