Class PpidChecker

java.lang.Object
org.apache.maven.surefire.booter.PpidChecker

final class PpidChecker extends Object
Recognizes PID of Plugin process and determines lifetime.
Since:
2.20.1
  • Field Details

    • MINUTES_TO_MILLIS

      private static final long MINUTES_TO_MILLIS
      See Also:
    • WMIC_CREATION_DATE_VALUE_LENGTH

      private static final int WMIC_CREATION_DATE_VALUE_LENGTH
      See Also:
    • WMIC_CREATION_DATE_TIMESTAMP_LENGTH

      private static final int WMIC_CREATION_DATE_TIMESTAMP_LENGTH
      See Also:
    • WMIC_CREATION_DATE_FORMAT

      private static final SimpleDateFormat WMIC_CREATION_DATE_FORMAT
    • WMIC_CREATION_DATE

      private static final String WMIC_CREATION_DATE
      See Also:
    • WINDOWS_SYSTEM_ROOT_ENV

      private static final String WINDOWS_SYSTEM_ROOT_ENV
      See Also:
    • RELATIVE_PATH_TO_WMIC

      private static final String RELATIVE_PATH_TO_WMIC
      See Also:
    • SYSTEM_PATH_TO_WMIC

      private static final String SYSTEM_PATH_TO_WMIC
      See Also:
    • PS_ETIME_HEADER

      private static final String PS_ETIME_HEADER
      See Also:
    • PS_PID_HEADER

      private static final String PS_PID_HEADER
      See Also:
    • destroyableCommands

      private final Queue<Process> destroyableCommands
    • UNIX_CMD_OUT_PATTERN

      static final Pattern UNIX_CMD_OUT_PATTERN
      The etime is in the form of [[dd-]hh:]mm:ss on Unix like systems. See the workaround https://issues.apache.org/jira/browse/SUREFIRE-1451.
    • BUSYBOX_CMD_OUT_PATTERN

      static final Pattern BUSYBOX_CMD_OUT_PATTERN
    • ppid

      private final String ppid
    • parentProcessInfo

      private volatile ProcessInfo parentProcessInfo
    • stopped

      private volatile boolean stopped
  • Constructor Details

    • PpidChecker

      PpidChecker(@Nonnull String ppid)
  • Method Details

    • canUse

      boolean canUse()
    • isProcessAlive

      boolean isProcessAlive()
      This method can be called only after canUse() has returned true.
      Returns:
      true if parent process is alive; false otherwise
      Throws:
      IllegalStateException - if canUse() returns false, error to read process or this object has been destroyed
      NullPointerException - if extracted e-time is null
    • checkProcessInfo

      private void checkProcessInfo()
    • unix

      ProcessInfo unix()
    • windows

      ProcessInfo windows()
    • destroyActiveCommands

      void destroyActiveCommands()
    • isStopped

      boolean isStopped()
    • unixPathToPS

      private static String unixPathToPS()
    • canExecuteUnixPs

      static boolean canExecuteUnixPs()
    • canExecuteLocalUnixPs

      private static boolean canExecuteLocalUnixPs()
    • canExecuteStandardUnixPs

      private static boolean canExecuteStandardUnixPs()
    • hasWmicStandardSystemPath

      private static boolean hasWmicStandardSystemPath()
    • fromDays

      static long fromDays(Matcher matcher)
    • fromHours

      static long fromHours(Matcher matcher)
    • fromMinutes

      static long fromMinutes(Matcher matcher)
    • fromSeconds

      static long fromSeconds(Matcher matcher)
    • fromPID

      static String fromPID(Matcher matcher)
    • fromBusyboxHours

      static long fromBusyboxHours(Matcher matcher)
    • fromBusyboxMinutes

      static long fromBusyboxMinutes(Matcher matcher)
    • fromBusyboxPID

      static String fromBusyboxPID(Matcher matcher)
    • checkValid

      private static void checkValid(Scanner scanner) throws IOException
      Throws:
      IOException
    • createWindowsCreationDateFormat

      private static SimpleDateFormat createWindowsCreationDateFormat()
      The beginning part of Windows WMIC format yyyymmddHHMMSS.xxx
      https://technet.microsoft.com/en-us/library/ee198928.aspx
      We use UTC time zone which avoids DST changes, see SUREFIRE-1512.
      Returns:
      Windows WMIC format yyyymmddHHMMSS.xxx
    • stop

      public void stop()
    • toString

      public String toString()
      Overrides:
      toString in class Object