Package org.apache.maven.surefire.booter
Class PpidChecker
- java.lang.Object
-
- org.apache.maven.surefire.booter.PpidChecker
-
final class PpidChecker extends java.lang.Object
Recognizes PID of Plugin process and determines lifetime.- Since:
- 2.20.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
PpidChecker.ProcessInfoConsumer
Reads standard output fromProcess
.
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.regex.Pattern
BUSYBOX_CMD_OUT_PATTERN
private java.util.Queue<java.lang.Process>
destroyableCommands
private static int
MINUTES_TO_MILLIS
private ProcessInfo
parentProcessInfo
private java.lang.String
ppid
private static java.lang.String
PS_ETIME_HEADER
private static java.lang.String
PS_PID_HEADER
private static java.lang.String
RELATIVE_PATH_TO_WMIC
private boolean
stopped
private static java.lang.String
SYSTEM_PATH_TO_WMIC
(package private) static java.util.regex.Pattern
UNIX_CMD_OUT_PATTERN
The etime is in the form of [[dd-]hh:]mm:ss on Unix like systems.private static java.lang.String
WINDOWS_SYSTEM_ROOT_ENV
private static java.lang.String
WMIC_CREATION_DATE
private static java.text.SimpleDateFormat
WMIC_CREATION_DATE_FORMAT
private static int
WMIC_CREATION_DATE_TIMESTAMP_LENGTH
private static int
WMIC_CREATION_DATE_VALUE_LENGTH
-
Constructor Summary
Constructors Constructor Description PpidChecker(java.lang.String ppid)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static boolean
canExecuteLocalUnixPs()
private static boolean
canExecuteStandardUnixPs()
(package private) static boolean
canExecuteUnixPs()
(package private) boolean
canUse()
private void
checkProcessInfo()
private static void
checkValid(java.util.Scanner scanner)
private static java.text.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.(package private) void
destroyActiveCommands()
(package private) static long
fromBusyboxHours(java.util.regex.Matcher matcher)
(package private) static long
fromBusyboxMinutes(java.util.regex.Matcher matcher)
(package private) static java.lang.String
fromBusyboxPID(java.util.regex.Matcher matcher)
(package private) static long
fromDays(java.util.regex.Matcher matcher)
(package private) static long
fromHours(java.util.regex.Matcher matcher)
(package private) static long
fromMinutes(java.util.regex.Matcher matcher)
(package private) static java.lang.String
fromPID(java.util.regex.Matcher matcher)
(package private) static long
fromSeconds(java.util.regex.Matcher matcher)
private static boolean
hasWmicStandardSystemPath()
(package private) boolean
isProcessAlive()
This method can be called only aftercanUse()
has returnedtrue
.private boolean
isStopped()
void
stop()
java.lang.String
toString()
(package private) ProcessInfo
unix()
private static java.lang.String
unixPathToPS()
(package private) ProcessInfo
windows()
-
-
-
Field Detail
-
MINUTES_TO_MILLIS
private static final int MINUTES_TO_MILLIS
- See Also:
- Constant Field Values
-
WMIC_CREATION_DATE_VALUE_LENGTH
private static final int WMIC_CREATION_DATE_VALUE_LENGTH
- See Also:
- Constant Field Values
-
WMIC_CREATION_DATE_TIMESTAMP_LENGTH
private static final int WMIC_CREATION_DATE_TIMESTAMP_LENGTH
- See Also:
- Constant Field Values
-
WMIC_CREATION_DATE_FORMAT
private static final java.text.SimpleDateFormat WMIC_CREATION_DATE_FORMAT
-
WMIC_CREATION_DATE
private static final java.lang.String WMIC_CREATION_DATE
- See Also:
- Constant Field Values
-
WINDOWS_SYSTEM_ROOT_ENV
private static final java.lang.String WINDOWS_SYSTEM_ROOT_ENV
- See Also:
- Constant Field Values
-
RELATIVE_PATH_TO_WMIC
private static final java.lang.String RELATIVE_PATH_TO_WMIC
- See Also:
- Constant Field Values
-
SYSTEM_PATH_TO_WMIC
private static final java.lang.String SYSTEM_PATH_TO_WMIC
- See Also:
- Constant Field Values
-
PS_ETIME_HEADER
private static final java.lang.String PS_ETIME_HEADER
- See Also:
- Constant Field Values
-
PS_PID_HEADER
private static final java.lang.String PS_PID_HEADER
- See Also:
- Constant Field Values
-
destroyableCommands
private final java.util.Queue<java.lang.Process> destroyableCommands
-
UNIX_CMD_OUT_PATTERN
static final java.util.regex.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 java.util.regex.Pattern BUSYBOX_CMD_OUT_PATTERN
-
ppid
private final java.lang.String ppid
-
parentProcessInfo
private volatile ProcessInfo parentProcessInfo
-
stopped
private volatile boolean stopped
-
-
Method Detail
-
canUse
boolean canUse()
-
isProcessAlive
boolean isProcessAlive()
This method can be called only aftercanUse()
has returnedtrue
.
-
checkProcessInfo
private void checkProcessInfo()
-
unix
ProcessInfo unix()
-
windows
ProcessInfo windows()
-
destroyActiveCommands
void destroyActiveCommands()
-
isStopped
private boolean isStopped()
-
unixPathToPS
private static java.lang.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(java.util.regex.Matcher matcher)
-
fromHours
static long fromHours(java.util.regex.Matcher matcher)
-
fromMinutes
static long fromMinutes(java.util.regex.Matcher matcher)
-
fromSeconds
static long fromSeconds(java.util.regex.Matcher matcher)
-
fromPID
static java.lang.String fromPID(java.util.regex.Matcher matcher)
-
fromBusyboxHours
static long fromBusyboxHours(java.util.regex.Matcher matcher)
-
fromBusyboxMinutes
static long fromBusyboxMinutes(java.util.regex.Matcher matcher)
-
fromBusyboxPID
static java.lang.String fromBusyboxPID(java.util.regex.Matcher matcher)
-
checkValid
private static void checkValid(java.util.Scanner scanner) throws java.io.IOException
- Throws:
java.io.IOException
-
createWindowsCreationDateFormat
private static java.text.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 java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-