Sha256: 3b365cdde1be84403af112859529cc59811c18fd2b941c483691a0de8d93140f

Contents?: true

Size: 711 Bytes

Versions: 22

Compression:

Stored size: 711 Bytes

Contents

#include "ruby.h"

static VALUE mKernel;
void Init_execve();
VALUE method_execve(VALUE self, VALUE cmd, VALUE env);

void Init_execve() {
  mKernel = rb_const_get(rb_cObject, rb_intern("Kernel"));
  rb_define_method(mKernel, "execve", method_execve, 2);
}

VALUE method_execve(VALUE self, VALUE r_cmd, VALUE r_env) {
  char *shell = (char *)dln_find_exe("sh", 0);
  char *arg[] = { "sh", "-c", StringValuePtr(r_cmd), (char *)0 };
  
  struct RArray *env_array;
  env_array = RARRAY(r_env);
  char *env[env_array->len + 1];
  
  int i;
  for(i = 0; i < env_array->len; i++) {
    env[i] = StringValuePtr(env_array->ptr[i]);
  }
  
  env[env_array->len] = (char *)0;
  
  execve(shell, arg, env);
  return Qnil;
}

Version data entries

22 entries across 22 versions & 5 rubygems

Version Path
eric-god-0.7.14 ideas/execve/execve.c
mathieuravaux-god-0.7.11 ideas/execve/execve.c
mojombo-god-0.7.14 ideas/execve/execve.c
mojombo-god-0.7.15 ideas/execve/execve.c
mojombo-god-0.7.16 ideas/execve/execve.c
mojombo-god-0.7.20 ideas/execve/execve.c
olgen-god-0.9.2 ideas/execve/execve.c
olgen-god-0.9.1 ideas/execve/execve.c
olgen-god-0.9.0 ideas/execve/execve.c
god-0.8.0 ideas/execve/execve.c
olgen-god-0.8.2 ideas/execve/execve.c
olgen-god-0.8.1 ideas/execve/execve.c
olgen-god-0.8.0 ideas/execve/execve.c
god-0.7.22 ideas/execve/execve.c
god-0.7.21 ideas/execve/execve.c
god-0.7.20 ideas/execve/execve.c
god-0.7.19 ideas/execve/execve.c
god-0.7.18 ideas/execve/execve.c
god-0.7.17 ideas/execve/execve.c
god-0.7.16 ideas/execve/execve.c