Crash with gnome gui and Kernel.exec

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.

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
Exec replaces the current process, so thats why your gui exits.

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

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.