Permalink
Browse files

Add higher level exec() and make execv() only expose that C function …

…if available
  • Loading branch information...
1 parent 4eed58d commit 9555cb9f941085d8d8987bc3ec9dbcf39540eaaf @enebo enebo committed Apr 7, 2011
View
13 src/org/jruby/ext/posix/BaseNativePOSIX.java
@@ -41,6 +41,15 @@ public int chmod(String filename, int mode) {
public int chown(String filename, int user, int group) {
return libc().chown(filename, user, group);
}
+
+ public int exec(String path, String[] args) {
+ handler.unimplementedError("exec unimplemented");
+ return -1;
+ }
+
+ public int execv(String path, String[] args) {
+ return libc().execv(path, args);
+ }
public FileStat fstat(FileDescriptor fileDescriptor) {
FileStat stat = allocateStat();
@@ -263,10 +272,6 @@ public int errno() {
public void errno(int value) {
LastError.setLastError(value);
}
-
- public int execv(String path, String[] args) {
- return libc().execv(path, args);
- }
public int aspawn(boolean overlay, String program, String[] argv, String path) {
handler.unimplementedError("aspawn only on windows platforms");
View
17 src/org/jruby/ext/posix/JavaPOSIX.java
@@ -31,6 +31,17 @@ public int chmod(String filename, int mode) {
public int chown(String filename, int user, int group) {
return helper.chown(filename, user, group);
}
+
+ public int exec(String path, String... argv) {
+ handler.unimplementedError("No exec in Java (yet)");
+
+ return -1;
+ }
+ public int execv(String path, String... argv) {
+ handler.unimplementedError("No execv in Java (yet)");
+
+ return -1;
+ }
public FileStat fstat(FileDescriptor descriptor) {
handler.unimplementedError("fstat unimplemented");
@@ -253,12 +264,6 @@ public void errno(int value) {
// do nothing, errno is unsupported
}
- public int execv(String path, String... argv) {
- handler.unimplementedError("No execv in Java (yet)");
-
- return -1;
- }
-
public boolean isNative() {
return false;
}
View
12 src/org/jruby/ext/posix/LazyPOSIX.java
@@ -57,7 +57,15 @@ public int errno() {
public void errno(int value) {
posix().errno(value);
}
+
+ public int exec(String path, String[] args) {
+ return posix().exec(path, args);
+ }
+ public int execv(String path, String... argv) {
+ return posix().execv(path, argv);
+ }
+
public int fork() {
return posix().fork();
}
@@ -238,10 +246,6 @@ public int waitpid(int pid, int[] status, int flags) {
return posix().waitpid(pid, status, flags);
}
- public int execv(String path, String... argv) {
- return posix().execv(path, argv);
- }
-
public boolean isNative() {
return posix().isNative();
}
View
7 src/org/jruby/ext/posix/POSIX.java
@@ -8,6 +8,12 @@
FileStat allocateStat();
int chmod(String filename, int mode);
int chown(String filename, int user, int group);
+ /**
+ * Shell expanding and escaping version of exec which handles all the
+ * preparation of a command line or command list.
+ */
+ int exec(String path, String... argv);
+ int execv(String path, String... argv);
int fork();
FileStat fstat(FileDescriptor descriptor);
int getegid();
@@ -55,7 +61,6 @@
int wait(int[] status);
int errno();
void errno(int value);
- int execv(String path, String... argv);
boolean isNative();
int aspawn(boolean overlay, String program, String[] argv, String path);
int spawn(boolean ovelay, String command, String program, String path);
View
14 src/org/jruby/ext/posix/WindowsPOSIX.java
@@ -139,12 +139,18 @@ public int chown(String filename, int user, int group) {
}
@Override
- public int execv(String path, String[] argv) {
- if (argv.length == 1) {
- return spawn(true, argv[0], null, path);
- }
+ public int exec(String path, String[] argv) {
+ if (argv.length == 1) return spawn(true, argv[0], null, path);
+
return aspawn(true, null, argv, path);
}
+
+ @Override
+ public int execv(String path, String[] argv) {
+ handler.unimplementedError("egid");
+
+ return -1;
+ }
@Override
public int getegid() {

0 comments on commit 9555cb9

Please sign in to comment.