posix 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/ext/posix/posix.c CHANGED
@@ -90,6 +90,7 @@ VALUE posix_execve(VALUE self, VALUE _binary, VALUE _argv, VALUE _envp) {
90
90
  * the programmer to set ARGV[0] to something
91
91
  * reasonable. */
92
92
  char** argv = malloc(sizeof(char*)*RARRAY_LEN(_argv) + 1);
93
+ argv[0] = NULL;
93
94
 
94
95
  for (i = 0; i < RARRAY_LEN(_argv); i++) {
95
96
  argv[i] = StringValuePtr(RARRAY_PTR(_argv)[i]);
@@ -99,14 +100,19 @@ VALUE posix_execve(VALUE self, VALUE _binary, VALUE _argv, VALUE _envp) {
99
100
  /* Construct our environment. Note that this totally ignores the precedent
100
101
  * set by Process#spawn, Kernel#exec and fiends */
101
102
 
102
- char **envp = malloc(sizeof(char**)*RHASH(_envp)->ntbl->num_entries + 1);
103
-
104
- keys = rb_hash_keys(_envp);
105
- for (i = 0; i < RARRAY_LEN(keys); i++) {
106
- akey = RARRAY_PTR(keys)[i];
107
- envk = rb_hash_aref(_envp, akey);
108
- asprintf(&envp[i], "%s=%s", StringValuePtr(akey), StringValuePtr(envk));
109
- envp[i+1] = NULL; /* Ensure that we're null terminated */
103
+ char **envp;
104
+ if (RHASH(_envp)->ntbl) {
105
+ envp = malloc(sizeof(char**)*RHASH(_envp)->ntbl->num_entries + 1);
106
+ keys = rb_hash_keys(_envp);
107
+ for (i = 0; i < RARRAY_LEN(keys); i++) {
108
+ akey = RARRAY_PTR(keys)[i];
109
+ envk = rb_hash_aref(_envp, akey);
110
+ asprintf(&envp[i], "%s=%s", StringValuePtr(akey), StringValuePtr(envk));
111
+ envp[i+1] = NULL; /* Ensure that we're null terminated */
112
+ }
113
+ } else {
114
+ envp = malloc(sizeof(char**));
115
+ envp[0] = NULL;
110
116
  }
111
117
 
112
118
  execve(binary, argv, envp);
data/lib/posix/sigset.rb CHANGED
@@ -12,6 +12,7 @@ class Posix
12
12
  end
13
13
 
14
14
  @signals << signal unless include? signal
15
+ self
15
16
  end
16
17
 
17
18
  def include?(signal)
data/posix.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "posix"
5
- s.version = "0.0.2"
5
+ s.version = "0.0.4"
6
6
  s.authors = ["Richo Healey"]
7
7
  s.email = ["richo@psych0tik.net"]
8
8
  s.homepage = "http://github.com/richo/ruby-posix"
data/test/sigprocmask.rb CHANGED
@@ -6,4 +6,4 @@ mask << "USR2"
6
6
 
7
7
  puts Posix.sigprocmask(Posix::SIG_SETMASK, mask)
8
8
 
9
- Posix.execve("/bin/bash", ["/bin/bash"], {"rawr" => "Thing"})
9
+ Posix.execve("/bin/bash", ["/bin/bash"], {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: