# KIlling a process inside a thread

**URL:** <https://www.ruby-forum.com/t/killing-a-process-inside-a-thread/194206>\
**Category:** Ruby\
**Created:** [September 1, 2010, 3:37am UTC](https://www.ruby-forum.com/t/killing-a-process-inside-a-thread/194206 "2010-09-01T03:37:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [September 1, 2010, 3:37am UTC](https://www.ruby-forum.com/t/killing-a-process-inside-a-thread/194206/1 "2010-09-01T03:37:52Z")

</div>

I have

```
@child_thread = Thread.new do
  # puts "#{ __FILE__ } @ #{ __LINE__ } #{Time.now}"

  stdout = `#{the_command}`
  @child_thread_return_status = $?
end

```

and later

```
#child_thread.kill

```

This apearrs to kill the thread but not the command surrounded by the  
back tick.

How do I kill the comand that is the backticked executable?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [September 1, 2010, 10:30am UTC](https://www.ruby-forum.com/t/killing-a-process-inside-a-thread/194206/2 "2010-09-01T10:30:32Z")

</div>

2010/9/1 Ralph S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> #child\_thread.kill
> 
> This apearrs to kill the thread but not the command surrounded by the back tick.
> 
> How do I kill the comand that is the backticked executable?

You probably better use IO.popen then which gives you access to the  
child’s PID. You’ll also need to handle the output returned from the  
process differently depending on timeout or not timeout.

Kind regards

robert
