< prev index next >

src/java.base/share/classes/java/lang/ProcessHandleImpl.java

Print this page
rev 12532 : 8131168: Refactor ProcessHandleImpl_*.c and add implememtation for AIX
Reviewed-by: rriggs, smarks

@@ -470,11 +470,11 @@
     }
 
     /**
      * Implementation of ProcessHandle.Info.
      * Information snapshot about a process.
-     * The attributes of a process vary by operating system and not available
+     * The attributes of a process vary by operating system and are not available
      * in all implementations.  Additionally, information about other processes
      * is limited by the operating system privileges of the process making the request.
      * If a value is not available, either a {@code null} or {@code -1} is stored.
      * The accessor methods return {@code null} if the value is not available.
      */

@@ -494,17 +494,19 @@
          * @param pid  of the native process
          */
         private native void info0(long pid);
 
         String command;
+        String commandLine;
         String[] arguments;
         long startTime;
         long totalTime;
         String user;
 
         Info() {
             command = null;
+            commandLine = null;
             arguments = null;
             startTime = -1L;
             totalTime = -1L;
             user = null;
         }

@@ -537,10 +539,19 @@
         public Optional<String> command() {
             return Optional.ofNullable(command);
         }
 
         @Override
+        public Optional<String> commandLine() {
+            if (command != null && arguments != null) {
+                return Optional.of(command + " " + String.join(" ", arguments));
+            } else {
+                return Optional.ofNullable(commandLine);
+            }
+        }
+
+        @Override
         public Optional<String[]> arguments() {
             return Optional.ofNullable(arguments);
         }
 
         @Override

@@ -578,10 +589,15 @@
             if (arguments != null && arguments.length > 0) {
                 if (sb.length() != 0) sb.append(", ");
                 sb.append("args: ");
                 sb.append(Arrays.toString(arguments));
             }
+            if (commandLine != null) {
+                if (sb.length() != 0) sb.append(", ");
+                sb.append("cmdLine: ");
+                sb.append(commandLine);
+            }
             if (startTime > 0) {
                 if (sb.length() != 0) sb.append(", ");
                 sb.append("startTime: ");
                 sb.append(startInstant());
             }
< prev index next >