src/solaris/classes/java/lang/ProcessImpl.java

Print this page

        

@@ -63,11 +63,13 @@
                          ProcessBuilder.Redirect[] redirects,
                          boolean redirectErrorStream)
         throws IOException
     {
         assert cmdarray != null && cmdarray.length > 0;
+        String prog = cmdarray[0];
 
+        try {
         // Convert arguments to a contiguous block; it's easier to do
         // memory management in Java than in C.
         byte[][] args = new byte[cmdarray.length-1][];
         int size = args.length; // For added NUL bytes
         for (int i = 0; i < args.length; i++) {

@@ -125,12 +127,16 @@
                                               redirects[2].append());
                     std_fds[2] = fdAccess.get(f2.getFD());
                 }
             }
 
+            SecurityManager security = System.getSecurityManager();
+            if (security != null) 
+                security.checkExec(prog);
+
         return new UNIXProcess
-            (toCString(cmdarray[0]),
+                (toCString(prog),
              argBlock, args.length,
              envBlock, envc[0],
              toCString(dir),
                  std_fds,
              redirectErrorStream);

@@ -141,7 +147,13 @@
             finally {
                 try { if (f1 != null) f1.close(); }
                 finally { if (f2 != null) f2.close(); }
             }
         }
+        } catch (IOException e) {
+            throw new IOException (
+                "Cannot run program \"" + prog + "\""
+                + (dir == null ? "" : " (in directory \"" + dir + "\")")
+                + ": " + e.getMessage(), e);
     }
+    }
 }