# Timeout and windows

**URL:** <https://www.ruby-forum.com/t/timeout-and-windows/102728>\
**Category:** Ruby\
**Created:** [March 27, 2007, 11:41am UTC](https://www.ruby-forum.com/t/timeout-and-windows/102728 "2007-03-27T11:41:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [March 27, 2007, 11:41am UTC](https://www.ruby-forum.com/t/timeout-and-windows/102728/1 "2007-03-27T11:41:32Z")

</div>

Hello,

I am using windows, which is probably the source of the problem.

I have a pipe that executes an external Ruby program, and i want to have  
a timeout on the pipe. The problem is that when the time is up the pipe  
process is not terminated. The pipe finishes its task and then returns  
in its own time; howver the timeout is acknowledged on its return - its  
just that the process is not interupted as it should be after t seconds.

I think this is probably a result of windows and threading, but is there  
a way around it while i continue to use windows?

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [March 27, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/timeout-and-windows/102728/2 "2007-03-27T16:33:44Z")

</div>

On Tue, 27 Mar 2007, Jamie wrote:

> I think this is probably a result of windows and threading, but is there  
> a way around it while i continue to use windows?

pipes and windows under ruby is a bad, bad idea unless you are very very  
careful. the definitely should not also put threads into the mix. the  
timeout library is implimented using a thread. take a look at this

# gem install systemu

[http://codeforpeople.com/lib/ruby/systemu/systemu-1.0.0/README](http://codeforpeople.com/lib/ruby/systemu/systemu-1.0.0/README)

samples/f.rb shows the facility you will need to kill the process if the  
time  
goes beyond a certain limit. it’s also safe to use systemu from inside  
a  
timeout block

Timeout.timeout(4) do  
system ‘ruby -e" sleep 42 "’  
end

regards.

-a
