<p>I ran <code>kubectl exec -it pod_XXXX -- top</code> command from my master node. Then killed the <code>kubectl exec</code> process by <code>sudo kill -9 &lt;pid_of_kubectl&gt;</code> command from another terminal.</p>

<pre><code> kubectl exec -it pod_XXXX -- top
 sudo kill -9 &lt;pid_of_kubectl_exec_command&gt;
</code></pre>

<p>Inside POD the <code>top</code> command keeps running.This issue is not seen when i press <code>crtl+c</code> to terminate the <code>kubectl exec</code>. Is it expected behavior?</p>

BEPP
<p>By running <strong>kubectl exec -it</strong> you're connecting/streaming your terminal to the pod terminal so that if you type anything to your terminal, streams to the pod terminal. That's why when you run <strong>kubectl exec -it pod_XXXX -- top</strong> on your terminal, it worked as expected. Remember, the POD's termial is running the <strong>top</strong> interface, not yours.</p>

<p>So, when you type <strong>sudo kill -9 pid_of_kubectl_exec_command</strong>, it kills the connection between your terminal and the POD's terminal. So, the process inside the POD's terminal keeps running.</p>

<p>When you press <strong>ctrl+c</strong> from your terminal, it streams <strong>ctrl+c</strong> to the POD terminal, that's why the <strong>top</strong> terminates instantly.</p>
