g_spawn_async from a reloadable module

Does g_spawn_async do something to make it incompatible with being
called from a module that is unloaded and reloaded? I am calling this
function from a Mozilla plug-in (the module is loaded an unloaded on a
per-page basis). The function is called once each time the module is
loaded. The first time always succeeds. Subsequent attempts tend to fail
with this error:

        Failed to execute child process "/home/braden/src/openvrml/openvrml-0.15/BUILD/mozilla-plugin/src/openvrml-player/.libs/openvrml-player" (Bad address)

It doesn't fail 100% of the time. Sometimes it works. If I wait a little
while between unloading and reloading, the odds of it working seem to
improve a bit.

The code around the call to g_spawn_async looks like this:

        using std::vector;
        using std::string;
        using boost::lexical_cast;
        this->window = reinterpret_cast<GdkNativeWindow>(window.window);
        const char * exec_path = g_getenv("OPENVRML_PLAYER");
        if (!exec_path) {
             exec_path = OPENVRML_LIBEXECDIR_ "/openvrml-player";
        vector<char> exec_path_vec(exec_path,
                                   exec_path + strlen(exec_path) + 1);
        string socket_id_arg =
            "--gtk-socket-id=" + lexical_cast<string>(this->window);
        const char * socket_id_arg_c_str = socket_id_arg.c_str();
        vector<char> socket_id_arg_vec(
            socket_id_arg_c_str + socket_id_arg.length() + 1);
        const char * uri_arg_c_str = this->initialURL.c_str();
        vector<char> uri_arg_vec(
            uri_arg_c_str + this->initialURL.length() + 1);
        char * argv[] = {
        const gchar * working_directory = 0;
        char ** envp = 0;
        GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD;
        GSpawnChildSetupFunc child_setup = 0;
        gpointer user_data = 0;
        GError * error = 0;
        bool succeeded = g_spawn_async(working_directory,
        if (!succeeded) {
            if (error) {

Braden McDaniel                           e-mail: <braden endoframe com>
<http://endoframe.com>                    Jabber: <braden jabber org>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]