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

Classes

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 SecurityException, IOException
 

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_CHECK_INTERVAL = 5
 
static final TimeUnit DEFAULT_CHECK_INTERVAL_UNITS = TimeUnit.SECONDS
 
static final Logger logger = Logger.getLogger(ExecUtil.class.getName())
 

Detailed Description

Executes a command line using an operating system process with a configurable timeout and pluggable logic to kill or continue the process on timeout.

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 termination check interval or process terminator.

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 I/O error occurs.

Definition at line 132 of file ExecUtil.java.

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

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

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.

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 I/O error occurs.

Definition at line 155 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_CHECK_INTERVAL, org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_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.

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 I/O error occurs.

Definition at line 178 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 280 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 328 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 401 of file ExecUtil.java.

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

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

Kills a process and its children

Parameters
processThe parent process to kill

Definition at line 235 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.waitForTermination().

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

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
SecurityExceptionIf a security manager exists and vetoes any aspect of running the process.
IOExceptionIf an I/O error occurs.

Definition at line 202 of file ExecUtil.java.

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

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_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_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.

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 260 of file ExecUtil.java.


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

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