31 return activeProcess !=
nullptr && activeProcess->isRunning();
36 return activeProcess !=
nullptr ? activeProcess->read (dest, numBytes) : 0;
41 return activeProcess ==
nullptr || activeProcess->killProcess();
46 return activeProcess !=
nullptr ? activeProcess->getExitCode() : 0;
77 result.
write (buffer, (
size_t) num);
86 class ChildProcessTests :
public UnitTest 89 ChildProcessTests() :
UnitTest (
"ChildProcess",
"Threads") {}
91 void runTest()
override 93 beginTest (
"Child Processes");
95 #if JUCE_WINDOWS || JUCE_MAC || JUCE_LINUX 99 expect (p.
start (
"tasklist"));
101 expect (p.
start (
"ls /"));
110 static ChildProcessTests childProcessUnitTests;
int readProcessOutput(void *destBuffer, int numBytesToRead)
Attempts to read some output from the child process.
bool waitForProcessToFinish(int timeoutMs) const
Blocks until the process is no longer running.
String readAllProcessOutput()
Blocks until the process has finished, and then returns its complete output as a string.
uint32 getExitCode() const
If the process has finished, this returns its exit code.
This is a base class for classes that perform a unit test.
bool isRunning() const
Returns true if the child process is alive.
bool write(const void *, size_t) override
Writes a block of data to the stream.
ChildProcess()
Creates a process object.
Launches and monitors a child process.
~ChildProcess()
Destructor.
static void JUCE_CALLTYPE sleep(int milliseconds)
Suspends the execution of the current thread until the specified timeout period has elapsed (note tha...
bool kill()
Attempts to kill the child process.
Writes data to an internal memory buffer, which grows as required.
String toString() const
Attempts to detect the encoding of the data and convert it to a string.
bool start(const String &command, int streamFlags=wantStdOut|wantStdErr)
Attempts to launch a child process command.
static uint32 getMillisecondCounter() noexcept
Returns the number of millisecs since a fixed event (usually system startup).