Vala bindings for vte_pty_spawn_async

I have the following piece of vala code:

Pid pid = 0;

try { terminal.pty = new Vte.Pty.sync(Vte.PtyFlags.DEFAULT); }
catch(Error e) { error(e.message); }

terminal.pty.spawn_async.begin(Environment.get_current_dir(), // working_directory
                               real_argv,                     // argv
                               env,                           // envv
                               SpawnFlags.DO_NOT_REAP_CHILD,  // spawn_flags
                               -1,                            // timeout
                               null,                          // cancellable
(obj, async_res) => {                                         // async callback
    try
    {
        // res = spawn_async's boolean result
        var res = terminal.pty.spawn_async.end(async_res, out pid); // child_pid
        debug("Res: %s, pid: %d", res.to_string(), pid);
    }
    catch(Error e) { warning(e.message); }
});

This code follows the documentation on https://valadoc.org/vte-2.91/Vte.Pty.spawn_async.html that states spawn_async protype is:

[ Version ( since = "0.48" ) ]
public async bool spawn_async (string? working_directory, string[] argv, string[]? envv, SpawnFlags spawn_flags, int timeout, Cancellable? cancellable, out Pid child_pid) throws Error

And here is the output I get:

../../../../../../../../../Projects/Experiment/src/window.vala: In function ‘experiment_window_construct’:
../../../../../../../../../Projects/Experiment/src/window.vala:53:2: error: too few arguments to function ‘vte_pty_spawn_async’
         terminal.pty.spawn_async.begin(Environment.get_current_dir(),
  ^      ~~~~~~~~~~~~
In file included from /app/include/vte-2.91/vte/vte.h:28,
                 from src/25a6634@@experiment@exe/window.c:24:
/app/include/vte-2.91/vte/vtepty.h:99:6: note: declared here
 void vte_pty_spawn_async(VtePty *pty,
      ^~~~~~~~~~~~~~~~~~~

I looked into the C code produced by valac and there really are fewer arguments than what the C function takes:

vte_pty_spawn_async (_tmp31_, _tmp33_, _tmp34_, _tmp35_, G_SPAWN_DO_NOT_REAP_CHILD, -1, NULL, ___lambda4__gasync_ready_callback, block1_data_ref (_data1_));
// Which human friendly translates to
vte_pty_spawn_async (pty, cwd, arv, envv, G_SPAWN_DO_NOT_REAP_CHILD, -1, NULL, async_callback, user_data);

According to the documentation this code is lacking child setup functions:

vte_pty_spawn_async (// [...]
                     GSpawnChildSetupFunc child_setup,
                     gpointer child_setup_data,
                     GDestroyNotify child_setup_data_destroy,
                     // [...]

I’ve tried everything I could to make this work with no success. Am I doing something wrong or is this really not working?


  • Vala version: 0.45.3.12-5744e
  • Vte-2.91 version: 0.57.4

It is indeed broken. For now, you can either use the deprecated Vte.Terminal.spawn_sync() or you can bundle a custom vapi for that method.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.