commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1165800 - /commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c
Date Tue, 06 Sep 2011 19:37:22 GMT
Author: mturk
Date: Tue Sep  6 19:37:22 2011
New Revision: 1165800

URL: http://svn.apache.org/viewvc?rev=1165800&view=rev
Log:
Fix solaris Vm.arguments

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c?rev=1165800&r1=1165799&r2=1165800&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c Tue Sep  6 19:37:22 2011
@@ -15,7 +15,9 @@
  */
 
 #include "acr/jniapi.h"
+#include "acr/clazz.h"
 #include "acr/string.h"
+#include "arch_opts.h"
 #include <procfs.h>
 #include <sys/utsname.h>
 #include <sys/systeminfo.h>
@@ -129,10 +131,10 @@ ACR_JNI_EXPORT(jobjectArray, Vm, arg0)(J
 {
     jobjectArray args = 0;
     psinfo_t pi;
-    int n, fd, rc;
+    int      rc;
     char   **sa;
 
-    if ((rc = selfpsinfo(-1, &pi)) != 0) {
+    if ((rc = selfpsinfo(&pi)) != 0) {
         ACR_THROW_SYS_ERROR(rc);
         return 0;
     }
@@ -140,44 +142,17 @@ ACR_JNI_EXPORT(jobjectArray, Vm, arg0)(J
         /* No arguments ? */
         return 0;
     }
-    if ((fd = open("/proc/self/as", O_RDONLY)) == -1) {
-        ACR_THROW_SYS_ERRNO();
-        return 0;
-    }
-    sa = ACR_MALLOC(char *, pi.pr_argc + 1);
-    if (sa == 0)
-        goto failed;
-    if (lseek(fd, pi.pr_argv, SEEK_SET) == -1) {
-        rc = ACR_GET_OS_ERROR();
-        goto failed;
-    }
-    if (read(fd, sa, sizeof(char *) * (pi.pr_argc + 1)) < 0) {
-        rc = ACR_GET_OS_ERROR();
-        goto failed;
-    }
+    sa = (char **)pi.pr_argv;
     args = AcrNewCoreObjectArray(env, ACR_CC_STRING, pi.pr_argc);
-    if (args == 0)
-        goto failed;
-    for (n = 0; n < pi.pr_argc; n++) {
-        jstring s;
-        char pname[8192] = "";
-        if (lseek(fd, (off_t) sa[n], SEEK_SET) != -1) {
-            if (read(fd, pname, sizeof(pname)) == -1)
-                pname[0] = '\0';
-        }
-        s = AcrNewJavaStringA(pname);
-        if (s != 0) {
+    if (args != 0) {
+        int n;
+        for (n = 0; n < pi.pr_argc; n++) {
+            jstring s = AcrNewJavaStringA(env, sa[n]);
+            if (s == 0)
+                break;
             (*env)->SetObjectArrayElement(env, args, n, s);
             (*env)->DeleteLocalRef(env, s);
         }
     }
-    close(fd);
-    AcrFree(args);
     return args;
-failed:
-    close(fd);
-    AcrFree(sa);
-    if (rc != 0)
-        ACR_THROW_SYS_ERROR(rc);
-    return 0;
 }



Mime
View raw message