# Weird behavior with exec /backticks

**URL:** <https://www.ruby-forum.com/t/weird-behavior-with-exec-backticks/197516>\
**Category:** Ruby\
**Created:** [October 15, 2010, 2:15pm UTC](https://www.ruby-forum.com/t/weird-behavior-with-exec-backticks/197516 "2010-10-15T14:15:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [October 15, 2010, 2:15pm UTC](https://www.ruby-forum.com/t/weird-behavior-with-exec-backticks/197516/1 "2010-10-15T14:15:10Z")

</div>

I have the following shell script that I call with backticks

> <https://gist.github.com/timuckun/626072>

What this script does it to execute the params passed but kill the  
process if a timeout expires.

When I run this script from the shell everything works just fine.  
Either the command finished before the timeout and the process exits  
or the the timeout kicks in and kill the process.

but when I run it like this

output = `#{executable} ‘#{param1}’ ‘#{param2}’ 45

it acts differently. If the command finished before the timeout the  
script does not exit. It waits the full timeout.

Can anybody explain this? That sub process should have been killed  
right away and the script should have returned but my script hangs for  
the full 45 seconds even if the command finishes in two seconds.
