posix 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/posix/posix.c +14 -8
- data/lib/posix/sigset.rb +1 -0
- data/posix.gemspec +1 -1
- data/test/sigprocmask.rb +1 -1
- metadata +1 -1
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
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
data/posix.gemspec
CHANGED
data/test/sigprocmask.rb
CHANGED