Exemplo n.º 1
0
static VALUE
term_fork_command(int argc, VALUE *argv, VALUE self)
{
    VALUE rb_command, rb_command_argv, rb_envv, rb_directory;
    VALUE lastlog, utmp, wtmp;
    char *command;
    char **command_argv;
    char **envv;
    char *directory;
    pid_t pid;

    rb_scan_args(argc, argv, "07", &rb_command, &rb_command_argv,
                 &rb_envv, &rb_directory, &lastlog, &utmp, &wtmp);

    command = NIL_P(rb_command) ? NULL : RVAL2CSTR(rb_command);
    command_argv = rval2cstrary(rb_command_argv);
    envv = rval2cstrary(rb_envv);
    directory = NIL_P(rb_directory) ? NULL : RVAL2CSTR(rb_directory);
    pid = vte_terminal_fork_command(RVAL2TERM(self), command,
                                    command_argv, envv, directory,
                                    NIL_P(lastlog) ? TRUE : RVAL2CBOOL(lastlog),
                                    NIL_P(utmp) ? TRUE : RVAL2CBOOL(utmp),
                                    NIL_P(wtmp) ? TRUE : RVAL2CBOOL(wtmp));
    free_cstrary(command_argv);
    free_cstrary(envv);

    return INT2NUM(pid);
}
Exemplo n.º 2
0
static VALUE
rg_fork_command(int argc, VALUE *argv, VALUE self)
{
    VALUE options, rb_pty_flags, rb_working_directory, rb_command_argv, rb_envv, rb_spawn_flags;
    int pty_flags, spawn_flags;
    char *working_directory;
    char **command_argv;
    char **envv;
    GPid child_pid;
    gboolean result;
    GError *error = NULL;

    rb_scan_args(argc, argv, "01", &options);
    rbg_scan_options(options,
                     "pty_flags", &rb_pty_flags,
                     "working_directory", &rb_working_directory,
                     "argv", &rb_command_argv,
                     "envv", &rb_envv,
                     "spawn_flags", &rb_spawn_flags,
                     NULL);
    pty_flags = NIL_P(rb_pty_flags) ?
                VTE_PTY_DEFAULT :
                RVAL2VTEPTYFLAGS(rb_pty_flags);
    working_directory = RVAL2CSTR_ACCEPT_NIL(rb_working_directory);
    command_argv = rval2cstrary(NIL_P(rb_command_argv) ? fork_command_default_argv() : rb_command_argv);
    envv = rval2cstrary(rb_envv);
    spawn_flags = NIL_P(rb_spawn_flags) ?
                G_SPAWN_CHILD_INHERITS_STDIN | G_SPAWN_SEARCH_PATH :
                NUM2INT(rb_spawn_flags);

    result = vte_terminal_fork_command_full(_SELF(self),
                                            pty_flags,
                                            working_directory,
                                            command_argv,
                                            envv,
                                            spawn_flags,
                                            NULL,
                                            NULL,
                                            &child_pid,
                                            &error);
    free_cstrary(command_argv);
    free_cstrary(envv);
    if (error)
        RAISE_GERROR(error);

    return INT2NUM(child_pid);
}
Exemplo n.º 3
0
static VALUE
rg_fork_command(int argc, VALUE *argv, VALUE self)
{
    VALUE rb_command, rb_command_argv, rb_envv, rb_directory;
    VALUE lastlog, utmp, wtmp;
    char *command;
    char **command_argv;
    char **envv;
    char *directory;
    pid_t pid;

    rb_scan_args(argc, argv, "07", &rb_command, &rb_command_argv,
                 &rb_envv, &rb_directory, &lastlog, &utmp, &wtmp);

#if VTE_CHECK_VERSION(0, 26, 0)
    if (argc == 0 || TYPE(rb_command) == T_HASH)
        return fork_command_full(1, &rb_command, self);

    rb_warn("'fork_commad(command, argv, envv, directory, lastlog, utmp, wtmp)' style"
            " has been deprecated since version 0.26."
            " Use 'fork_commad(options = {})' style.");
#endif

    command = NIL_P(rb_command) ? NULL : RVAL2CSTR(rb_command);
    command_argv = rval2cstrary(rb_command_argv);
    envv = rval2cstrary(rb_envv);
    directory = NIL_P(rb_directory) ? NULL : RVAL2CSTR(rb_directory);
    pid = vte_terminal_fork_command(RVAL2TERM(self), command,
                                    command_argv, envv, directory,
                                    NIL_P(lastlog) ? TRUE : RVAL2CBOOL(lastlog),
                                    NIL_P(utmp) ? TRUE : RVAL2CBOOL(utmp),
                                    NIL_P(wtmp) ? TRUE : RVAL2CBOOL(wtmp));
    free_cstrary(command_argv);
    free_cstrary(envv);

    return INT2NUM(pid);
}