Autopsy  4.18.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Classes | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.sleuthkit.autopsy.coreutils.ExecUtil Class Reference

Classes

class  HybridTerminator
 
class  InterruptedThreadProcessTerminator
 
interface  ProcessTerminator
 
class  StreamToStringRedirect
 
class  StreamToWriterRedirect
 
class  TimedProcessTerminator
 

Public Member Functions

synchronized String execute (final String aCommand, final String...params) throws IOException, InterruptedException
 
synchronized void execute (final Writer stdoutWriter, final String aCommand, final String...params) throws IOException, InterruptedException
 
synchronized int getExitValue ()
 
synchronized void stop ()
 

Static Public Member Functions

static int execute (ProcessBuilder processBuilder) throws SecurityException, IOException
 
static int execute (ProcessBuilder processBuilder, ProcessTerminator terminator) throws SecurityException, IOException
 
static int execute (ProcessBuilder processBuilder, long terminationCheckInterval, TimeUnit units, ProcessTerminator terminator) throws SecurityException, IOException
 
static void killProcess (Process process)
 
static int waitForTermination (String processName, Process process, long terminationCheckInterval, TimeUnit units, ProcessTerminator terminator) throws IOException
 

Static Private Member Functions

static void terminateProcess (String processName, Process process) throws IOException, InterruptedException
 
static int waitForProcess (String processName, Process process, long terminationCheckInterval, TimeUnit units, ProcessTerminator terminator) throws IOException, InterruptedException
 

Private Attributes

ExecUtil.StreamToStringRedirect errorStringRedirect = null
 
int exitValue = -100
 
ExecUtil.StreamToStringRedirect outputStringRedirect = null
 
ExecUtil.StreamToWriterRedirect outputWriterRedirect = null
 
Process proc = null
 

Static Private Attributes

static final long DEFAULT_TERMINATION_CHECK_INTERVAL = 5
 
static final TimeUnit DEFAULT_TERMINATION_CHECK_INTERVAL_UNITS = TimeUnit.SECONDS
 
static final Logger logger = Logger.getLogger(ExecUtil.class.getName())
 
static final long MAX_WAIT_FOR_TERMINATION = 1
 
static final TimeUnit MAX_WAIT_FOR_TERMINATION_UNITS = TimeUnit.MINUTES
 

Detailed Description

Executes a command line using an operating system process with pluggable logic to terminate the process under certain conditions.

Definition at line 37 of file ExecUtil.java.

Member Function Documentation

static int org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( ProcessBuilder  processBuilder) throws SecurityException, IOException
static

Runs a process without a process terminator. This method should be used with caution because there is nothing to stop the process from running forever.

IMPORTANT: This method blocks while the process is running. For legacy API reasons, if there is an interrupt the InterruptedException is wrapped in an IOException instead of being thrown. Callers that need to know about interrupts to detect backgound task cancellation can call Thread.isInterrupted() or, if the thread's interrupt flag should be cleared, Thread.interrupted().

Parameters
processBuilderA process builder used to configure and construct the process to be run.
Returns
The exit value of the process.
Exceptions
SecurityExceptionIf a security manager exists and vetoes any aspect of running the process.
IOExceptionIf an error occurs while executing or terminating the process.

Definition at line 172 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.execute().

Referenced by org.sleuthkit.autopsy.modules.pictureanalyzer.impls.HEICProcessor.convertToJPEG(), org.sleuthkit.autopsy.coreutils.ExecUtil.execute(), org.sleuthkit.autopsy.casemodule.LocalFilesDSProcessor.extractLogicalEvidenceFileContents(), org.sleuthkit.autopsy.modules.leappanalyzers.ALeappAnalyzerIngestModule.process(), org.sleuthkit.autopsy.modules.leappanalyzers.ILeappAnalyzerIngestModule.process(), org.sleuthkit.autopsy.modules.plaso.PlasoIngestModule.process(), org.sleuthkit.autopsy.modules.leappanalyzers.ALeappAnalyzerIngestModule.processALeappFile(), org.sleuthkit.autopsy.modules.leappanalyzers.ALeappAnalyzerIngestModule.processALeappFs(), org.sleuthkit.autopsy.modules.leappanalyzers.ILeappAnalyzerIngestModule.processILeappFile(), and org.sleuthkit.autopsy.modules.leappanalyzers.ILeappAnalyzerIngestModule.processILeappFs().

static int org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( ProcessBuilder  processBuilder,
ProcessTerminator  terminator 
) throws SecurityException, IOException
static

Runs a process using the default termination check interval and a process terminator.

IMPORTANT: This method blocks while the process is running. For legacy API reasons, if there is an interrupt the InterruptedException is wrapped in an IOException instead of being thrown. Callers that need to know about interrupts to detect backgound task cancellation can call Thread.isInterrupted() or, if the thread's interrupt flag should be cleared, Thread.interrupted().

Parameters
processBuilderA process builder used to configure and construct the process to be run.
terminatorThe terminator.
Returns
The exit value of the process.
Exceptions
SecurityExceptionIf a security manager exists and vetoes any aspect of running the process.
IOExceptionIf an error occurs while executing or terminating the process.

Definition at line 203 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_TERMINATION_CHECK_INTERVAL, org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_TERMINATION_CHECK_INTERVAL_UNITS, and org.sleuthkit.autopsy.coreutils.ExecUtil.execute().

static int org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( ProcessBuilder  processBuilder,
long  terminationCheckInterval,
TimeUnit  units,
ProcessTerminator  terminator 
) throws SecurityException, IOException
static

Runs a process using a custom termination check interval and a process terminator.

IMPORTANT: This method blocks while the process is running. For legacy API reasons, if there is an interrupt the InterruptedException is wrapped in an IOException instead of being thrown. Callers that need to know about interrupts to detect backgound task cancellation can call Thread.isInterrupted() or, if the thread's interrupt flag should be cleared, Thread.interrupted().

Parameters
processBuilderA process builder used to configure and construct the process to be run.
terminationCheckIntervalThe interval at which to query the process terminator to see if the process should be killed.
unitsThe units for the termination check interval.
terminatorThe terminator.
Returns
The exit value of the process.
Exceptions
SecurityExceptionIf a security manager exists and vetoes any aspect of running the process.
IOExceptionIf an error occurs while executing or terminating the process.

Definition at line 234 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.waitForTermination().

synchronized String org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( final String  aCommand,
final String...  params 
) throws IOException, InterruptedException

Execute a process. Redirect asynchronously stdout to a string and stderr to nowhere. Use only for small outputs, otherwise use the execute() variant with Writer.

Parameters
aCommandcommand to be executed
paramsparameters of the command
Returns
string buffer with captured stdout
Exceptions
java.io.IOException
java.lang.InterruptedException

Definition at line 422 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.errorStringRedirect, and org.sleuthkit.autopsy.coreutils.ExecUtil.outputStringRedirect.

synchronized void org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( final Writer  stdoutWriter,
final String  aCommand,
final String...  params 
) throws IOException, InterruptedException

Execute a process. Redirect asynchronously stdout to a passed in writer and stderr to nowhere.

Parameters
stdoutWriterfile writer to write stdout to
aCommandcommand to be executed
paramsparameters of the command
Exceptions
java.io.IOException
java.lang.InterruptedException

Definition at line 470 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.errorStringRedirect, and org.sleuthkit.autopsy.coreutils.ExecUtil.outputWriterRedirect.

synchronized int org.sleuthkit.autopsy.coreutils.ExecUtil.getExitValue ( )

Gets the exit value returned by the subprocess used to execute a command.

Returns
The exit value or the distinguished value -100 if this method is called before the exit value is set.

Definition at line 543 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.exitValue.

static void org.sleuthkit.autopsy.coreutils.ExecUtil.killProcess ( Process  process)
static

Terminates a process and its children, waiting with a time out to try to ensure the process is no longer alive before returning.

IMPORTANT: This method blocks while the process is running. For legacy API reasons, if there is an interrupt (or any other exception) the exception is logged instead of being thrown. Callers that need to know about interrupts to detect backgound task cancellation can call Thread.isInterrupted() or, if the thread's interrupt flag should be cleared, Thread.interrupted().

Parameters
processThe process.

Definition at line 344 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.terminateProcess().

synchronized void org.sleuthkit.autopsy.coreutils.ExecUtil.stop ( )
static void org.sleuthkit.autopsy.coreutils.ExecUtil.terminateProcess ( String  processName,
Process  process 
) throws IOException, InterruptedException
staticprivate

Terminates a process and its children, waiting with a time out to try to ensure the process is no longer alive before returning.

Parameters
processNameThe name of the process, for logging purposes.
processThe process.
Exceptions
IOExceptionIf an error occurs while trying to terminate the process.
InterruptedExceptionIf the thread running this code is interrupted while waiting for the process to terminate.

Definition at line 369 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.Win32Process.getChildren(), and org.sleuthkit.autopsy.coreutils.Win32Process.terminate().

Referenced by org.sleuthkit.autopsy.coreutils.ExecUtil.killProcess(), and org.sleuthkit.autopsy.coreutils.ExecUtil.waitForProcess().

static int org.sleuthkit.autopsy.coreutils.ExecUtil.waitForProcess ( String  processName,
Process  process,
long  terminationCheckInterval,
TimeUnit  units,
ProcessTerminator  terminator 
) throws IOException, InterruptedException
staticprivate

Waits for an existing process to finish, using a custom termination check interval and a process terminator.

Parameters
processNameThe name of the process, for logging purposes.
processThe process.
terminationCheckIntervalThe interval at which to query the process terminator to see if the process should be killed.
unitsThe units for the termination check interval.
terminatorThe process terminator.
Returns
The exit value of the process.
Exceptions
IOExceptionIf an error occurs while executing or terminating the process.
InterruptedExceptionIf the thread running this code is interrupted while the process is running.

Definition at line 298 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.terminateProcess().

Referenced by org.sleuthkit.autopsy.coreutils.ExecUtil.waitForTermination().

static int org.sleuthkit.autopsy.coreutils.ExecUtil.waitForTermination ( String  processName,
Process  process,
long  terminationCheckInterval,
TimeUnit  units,
ProcessTerminator  terminator 
) throws IOException
static

Waits for an existing process to finish, using a custom termination check interval and a process terminator.

IMPORTANT: This method blocks while the process is running. For legacy API reasons, if there is an interrupt the InterruptedException is wrapped in an IOException instead of being thrown. Callers that need to know about interrupts to detect backgound task cancellation can call Thread.isInterrupted() or, if the thread's interrupt flag should be cleared, Thread.interrupted().

Parameters
processNameThe name of the process, for logging purposes.
processThe process.
terminationCheckIntervalThe interval at which to query the process terminator to see if the process should be killed.
unitsThe units for the termination check interval.
terminatorThe process terminator.
Returns
The exit value of the process.
Exceptions
IOExceptionIf an error occurs while executing or terminating the process.

Definition at line 264 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.waitForProcess().

Referenced by org.sleuthkit.autopsy.coreutils.ExecUtil.execute(), and org.sleuthkit.autopsy.modules.plaso.PlasoIngestModule.process().

Member Data Documentation

final long org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_TERMINATION_CHECK_INTERVAL = 5
staticprivate

Definition at line 40 of file ExecUtil.java.

Referenced by org.sleuthkit.autopsy.coreutils.ExecUtil.execute().

final TimeUnit org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_TERMINATION_CHECK_INTERVAL_UNITS = TimeUnit.SECONDS
staticprivate

Definition at line 41 of file ExecUtil.java.

Referenced by org.sleuthkit.autopsy.coreutils.ExecUtil.execute().

ExecUtil.StreamToStringRedirect org.sleuthkit.autopsy.coreutils.ExecUtil.errorStringRedirect = null
private
int org.sleuthkit.autopsy.coreutils.ExecUtil.exitValue = -100
private
final Logger org.sleuthkit.autopsy.coreutils.ExecUtil.logger = Logger.getLogger(ExecUtil.class.getName())
staticprivate

Definition at line 39 of file ExecUtil.java.

final long org.sleuthkit.autopsy.coreutils.ExecUtil.MAX_WAIT_FOR_TERMINATION = 1
staticprivate

Definition at line 42 of file ExecUtil.java.

final TimeUnit org.sleuthkit.autopsy.coreutils.ExecUtil.MAX_WAIT_FOR_TERMINATION_UNITS = TimeUnit.MINUTES
staticprivate

Definition at line 43 of file ExecUtil.java.

ExecUtil.StreamToStringRedirect org.sleuthkit.autopsy.coreutils.ExecUtil.outputStringRedirect = null
private
ExecUtil.StreamToWriterRedirect org.sleuthkit.autopsy.coreutils.ExecUtil.outputWriterRedirect = null
private
Process org.sleuthkit.autopsy.coreutils.ExecUtil.proc = null
private

Definition at line 402 of file ExecUtil.java.


The documentation for this class was generated from the following file:

Copyright © 2012-2021 Basis Technology. Generated on: Thu Jul 8 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.