, , , Solaris .
, , 10 , "ls", 10 .
Solaris 10 , Linux , " ". .
http://developers.sun.com/solaris/articles/subprocess/subprocess.html
Unix : fork(), exec(). fork() , exec() .
(. Solaris " " , . Unix , . , " " (VM) .)
, fork/exec . , fork.
: fork() - , fork() . , fork() exec(), . , .
, , 64- 6 () VM , ls (1). fork(), , 6 . VM ( ), fork() ENOMEM. , ls (1) 6 , fork() .
, Sun . , dbx Sun RFE ( ): "4748951 dbx posix_spawn() , fork (2)".
RFE 4748951 , dbx script, cut (1) dbx. - , - dbx . , dbx fork/exec cut (1) fork().
Java Solaris (JVM) , Sun RFE: "5049299 posix_spawn, fork, S10, swap".
, 3 .
1.- Runtime.exec .
2. java- Runtime.exec.
3.- JNI C. , .
.
Java.
public class CallOS {
static {
System.loadLibrary("CallOS");
}
public native int exec(java.lang.String cmd);
public static void main(String[] args) {
int returnValue = 0;
returnValue = new CallOS().exec("ls -la");
System.out.println("- " + returnValue);
}
}
C. javah -jni CallOS
#include <jni.h>
#ifndef _Included_CallOS
#define _Included_CallOS
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jint JNICALL Java_CallOS_exec
(JNIEnv *, jobject, jstring);
#ifdef __cplusplus
}
#endif
#endif
C-.
#include "CallOS.h"
#include <stdlib.h>
JNIEXPORT jint JNICALL Java_CallOS_exec
(JNIEnv *env, jobject obj, jstring cmd)
{
jint retval;
jbyte *str;
str = (*env)->GetStringUTFChars(env, cmd, NULL);
if(str == NULL) return NULL;
retval = system(str);
(*env)->ReleaseStringUTFChars(env, cmd, str);
return retval;
};
, .