# Crash with gnome gui and Kernel.exec

**URL:** <https://www.ruby-forum.com/t/crash-with-gnome-gui-and-kernel-exec/132430>\
**Category:** Ruby-Gnome 2\
**Created:** [March 20, 2008, 3:17am UTC](https://www.ruby-forum.com/t/crash-with-gnome-gui-and-kernel-exec/132430 "2008-03-20T03:17:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![euoar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/278dde/32.png) [@euoar](https://www.ruby-forum.com/u/euoar)\
**Post date:** [March 20, 2008, 3:17am UTC](https://www.ruby-forum.com/t/crash-with-gnome-gui-and-kernel-exec/132430/1 "2008-03-20T03:17:19Z")

</div>

Hello,

I’m writing an interface for a command line utility. When I press a  
start button, the callback calls Kernel.exec to make use of the command  
line utility, passing to it the information collected from the UI. Well,  
that’s what I wanted to do, cause what really happens is that the new  
process (the command line utility) starts, but the GUI crashes, without  
any message… Any ideas of why could be happening this crash? I’ve  
tried also making a thread for the Kernel.exec part, but it crashes  
too…

Here is the method that doesn’t work:

def button2\_clicked(widget)  
nombre\_destino = @entry1.text  
pelicula = @filechooserbutton1.filename  
subtitulos = @filechooserbutton2.filename  
size = @spinbutton1.value  
@thread = Thread.new {  
begin  
exec("mencoder -sub ‘#{subtitulos}’ -subfont-text-scale #{size}  
" +  
"’#{pelicula}’ -ovc lavc -lavcopts " +  
"vcodec=mpeg4:vhq:vbitrate=1000 -oac mp3lame " +  
“-lameopts br=256:vol=1 -ffourcc DIVX -o ‘#{nombre\_destino}’”)  
rescue  
puts “error”  
end  
}  
end

Thank you very much for your help.

---

<div class="post-metadata">

**Author:** ![euoar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/278dde/32.png) [@euoar](https://www.ruby-forum.com/u/euoar)\
**Post date:** [March 20, 2008, 10:53am UTC](https://www.ruby-forum.com/t/crash-with-gnome-gui-and-kernel-exec/132430/2 "2008-03-20T10:53:47Z")

</div>

euoar wrote:

> exec("mencoder -sub ‘#{subtitulos}’ -subfont-text-scale #{size}

You’re using the wrong command for your plan.  
Take a look at the rdoc  
[http://www.ruby-doc.org/core/classes/Kernel.html#M005979](http://www.ruby-doc.org/core/classes/Kernel.html#M005979)  
Exec _replaces_ the current process, so thats why your gui exits.

Instead of exec, you should use system or IO.popen.

---

<div class="post-metadata">

**Author:** ![euoar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/278dde/32.png) [@euoar](https://www.ruby-forum.com/u/euoar)\
**Post date:** [March 20, 2008, 12:25pm UTC](https://www.ruby-forum.com/t/crash-with-gnome-gui-and-kernel-exec/132430/3 "2008-03-20T12:25:31Z")

</div>

Joachim G. escribio’:

> Instead of exec, you should use system or IO.popen.

Right, that fixed the problem. Thank you very much for your help,  
Joachim.
