From: Masoom Date: 2008-05-21T14:23:53+09:00 Subject: Re: [ruby-core:16807] Embedding Ruby1.9: seg fault ------=_Part_17718_25217891.1211347427649 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello Guy, thanks, your suggestion with little thought worked for me this is the solution char *rbArgs[2]; rbArgs[0] = 0; // I feel this is not required, hence passing 0 rbArgs[1] = "my_cool_script.rb"; return ruby_run_node(ruby_options(2, rbArgs)); but am not 'satisfied' since I still maintain that rb_load_file() is cleaner than above solution what are your views ? just to give you the context here is abstract overview of my app main() { // init ruby VM // create few classes and globals for use in script // load the script // read those globals and proceed to initialize rest of app } inside script we manipulate the globals and available classes and they impact the main application behavior On Tue, May 20, 2008 at 8:51 PM, ts wrote: > Masoom wrote: > > yeah, thanks, but main.c was my reference for writing my own version :) > > in main.c it call ruby_options(argc, argv) not rb_load_file() > > replace rb_load_file() with ruby_options() and give it the right > value for argc and argv and it will work > > Look at load.c if you *REALLY* want to know how rb_load_file() > is used in ruby. > > > Guy Decoux > > ------=_Part_17718_25217891.1211347427649 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello Guy,

thanks, your suggestion with little thought worked for me

this is the solution
    char *rbArgs[2];
    rbArgs[0] = 0; // I feel this is not required, hence passing 0
    rbArgs[1] = "my_cool_script.rb";
    return ruby_run_node(ruby_options(2, rbArgs));

but am not 'satisfied' since I still maintain that rb_load_file() is cleaner than above solution
what are your views ?

just to give you the context here is abstract overview of my app

main()
{
    // init ruby VM
    // create few classes and globals for use in script
    // load the script
    // read those globals and proceed to initialize rest of app
}

inside script we manipulate the globals and available classes and they impact the main application behavior

On Tue, May 20, 2008 at 8:51 PM, ts <decoux@moulon.inra.fr> wrote:
Masoom wrote:
> yeah, thanks, but main.c was my reference for writing my own version :)

 in main.c it call ruby_options(argc, argv) not rb_load_file()

 replace rb_load_file() with ruby_options() and give it the right
 value for argc and argv and it will work

 Look at load.c if you *REALLY* want to know how rb_load_file()
 is used in ruby.


Guy Decoux


------=_Part_17718_25217891.1211347427649--