…(and potentialy other browsers which require full file name not starting with a .)
exec wants either multiple arguments, i.e., exec "prog", "arg1", "arg2". OR it wants a single string "prog arg1 arg2 ...". On OSX and when you want a program to use arguments when loading, you need to consider that the value of `app` is not just a single word (representing an application). In my case, `app="open -g -a Safari" because of OSX and because I want it to load in the background (-g).
The last attempt against zombie creation was unsuccessful because the reaping thread was aborted along with the main vim-ruby thread. If we double fork the browser program we can: * ensure that Process#detach will correctly setup and reap the grandchild process * create browser instances that are not children of the current vim This is essentially what Process#detach does when it works correctly
… $stdout, $stderr * Beware: if you fork, you must always reap, lest the dead rise again and clutter your process tables! * Regexp.escape is the wrong tool for shell escaping. Kernel#exec properly escapes parameters when given as separate arguments * Silence both $stdout and $stderr in the fork (not STDOUT and STDERR) Ruby 1.9 can handle all of the above in a nice little call: Process.detach spawn(program, arg1, arg2, [:out, :err] => '/dev/null')
There was some missing redirection code. Here is how the current commit redirects output. When searching for an app to run all output is redirected to /dev/null as the ruby "system" command return true/false based on the return code fo the application. Since we are looking at the 'which' command it will return 0 (true) if it finds the app and 1 (false) if it doesn't. When executing the viewer, stderr is redirected to stdout and stdout is redirected to /dev/null. Note that stderr is _not_ redirected to /dev/null because of order of redirection. However, this has the nice consequence of printing an error in the VIM window if the preview application cannot be called or has any err output.
Without an html extension, Safari will not open the resulting file. Also, in testing if the browser exists, it doesn't allow the addition of arguments on the call. Thus, there is also a change to the way existance of executable is checked. Splits the browser string and checks the first item.