[+] AuProcesses::IProcess::GetOutputAndInputHandles()

[+] AuProcesses::IProcess::GetErrorStreamHandle()
This commit is contained in:
Reece Wilson 2023-09-16 22:08:10 +01:00
parent 644c294c36
commit f13efd0cbf
5 changed files with 47 additions and 11 deletions

View File

@ -22,38 +22,38 @@ namespace Aurora::Processes
* using this over the loop source. Won't remove. Has legitmate * using this over the loop source. Won't remove. Has legitmate
* use cases. You could use this lock state as 'has terminated' * use cases. You could use this lock state as 'has terminated'
* @return * @return
*/ */
virtual AuSPtr<Threading::IWaitable> AsWaitable() = 0; virtual AuSPtr<Threading::IWaitable> AsWaitable() = 0;
/** /**
* @brief Kernel synchronization primitive to synchronize against the process * @brief Kernel synchronization primitive to synchronize against the process
* *
*/ */
virtual AuSPtr<IO::Loop::ILoopSource> AsLoopSource() = 0; virtual AuSPtr<IO::Loop::ILoopSource> AsLoopSource() = 0;
/** /**
* @brief returns the exit code of the process should we outlive them * @brief returns the exit code of the process should we outlive them
* @return * @return
*/ */
virtual AuSInt GetExitCode() = 0; virtual AuSInt GetExitCode() = 0;
/** /**
* @brief returns *something* about the process. you should not use this * @brief returns *something* about the process. you should not use this
* @return * @return
*/ */
virtual AuUInt GetProcessId() = 0; virtual AuUInt GetProcessId() = 0;
/** /**
* @brief Creates the process, for the first and only time, given the input * @brief Creates the process, for the first and only time, given the input
* StartupParameters provided to the relevant Spawn function * StartupParameters provided to the relevant Spawn function
* @return * @return
*/ */
virtual bool Start() = 0; virtual bool Start() = 0;
/** /**
* @brief Forcefully terminates the process * @brief Forcefully terminates the process
* @return * @return
*/ */
virtual bool Terminate() = 0; virtual bool Terminate() = 0;
/** /**
@ -62,7 +62,7 @@ namespace Aurora::Processes
terminate key sequence to the process terminate key sequence to the process
* @return whether or not the thread is still alive at the end of the kill * @return whether or not the thread is still alive at the end of the kill
* attempt. * attempt.
*/ */
virtual bool TryKill() = 0; virtual bool TryKill() = 0;
/** /**
@ -73,26 +73,38 @@ namespace Aurora::Processes
* If the input span is null, outVariable is assigned the available bytes in the IPC buffer * If the input span is null, outVariable is assigned the available bytes in the IPC buffer
* @param nonblock * @param nonblock
* @return * @return
*/ */
virtual bool Read(EStandardHandle stream, const Memory::MemoryViewStreamWrite &destination, bool nonblock = true) = 0; virtual bool Read(EStandardHandle stream, const Memory::MemoryViewStreamWrite &destination, bool nonblock = true) = 0;
/** /**
* @brief Synchronously writes `source` bytes to the processes stdin stream * @brief Synchronously writes `source` bytes to the processes stdin stream
* @param source * @param source
* @return * @return
*/ */
virtual bool Write(const Memory::MemoryViewStreamRead &source) = 0; virtual bool Write(const Memory::MemoryViewStreamRead &source) = 0;
/** /**
* @brief Returns an asynchronous file stream transaction of pipe pair: stdout, stdin * @brief Returns an asynchronous file stream transaction of pipe pair: stdout, stdin
* @return * @return
*/ */
virtual AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() = 0; virtual AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() = 0;
/** /**
* @brief Returns an asynchronous file stream transaction of pipe pair: stderr, INVALID * @brief Returns an asynchronous file stream transaction of pipe pair: stderr, INVALID
* @return * @return
*/ */
virtual AuSPtr<IO::IAsyncTransaction> NewErrorStreamAsyncTransaction() = 0; virtual AuSPtr<IO::IAsyncTransaction> NewErrorStreamAsyncTransaction() = 0;
/**
* @brief returns the handle backing NewAsyncTransaction
* @return
*/
virtual AuSPtr<IO::IIOHandle> GetOutputAndInputHandles() = 0;
/**
* @brief returns the handle backing NewErrorStreamAsyncTransaction
* @return
*/
virtual AuSPtr<IO::IIOHandle> GetErrorStreamHandle() = 0;
}; };
} }

View File

@ -496,6 +496,16 @@ namespace Aurora::Processes
return this->fsErrorStream_ ? this->fsErrorStream_->NewTransaction() : AuSPtr<AuIO::IAsyncTransaction> {}; return this->fsErrorStream_ ? this->fsErrorStream_->NewTransaction() : AuSPtr<AuIO::IAsyncTransaction> {};
} }
AuSPtr<IO::IIOHandle> ProcessImpl::GetOutputAndInputHandles()
{
return this->fsHandle_;
}
AuSPtr<IO::IIOHandle> ProcessImpl::GetErrorStreamHandle()
{
return this->fsErrorHandle_;
}
bool ProcessImpl::Start() bool ProcessImpl::Start()
{ {
if (this->process_ != INVALID_HANDLE_VALUE) if (this->process_ != INVALID_HANDLE_VALUE)

View File

@ -35,6 +35,8 @@ namespace Aurora::Processes
AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() override; AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() override;
AuSPtr<IO::IAsyncTransaction> NewErrorStreamAsyncTransaction() override; AuSPtr<IO::IAsyncTransaction> NewErrorStreamAsyncTransaction() override;
AuSPtr<IO::IIOHandle> GetOutputAndInputHandles() override;
AuSPtr<IO::IIOHandle> GetErrorStreamHandle() override;
bool Start() override; bool Start() override;

View File

@ -471,6 +471,16 @@ namespace Aurora::Processes
return this->fsErrorStream_ ? this->fsErrorStream_->NewTransaction() : AuSPtr<AuIO::IAsyncTransaction> {}; return this->fsErrorStream_ ? this->fsErrorStream_->NewTransaction() : AuSPtr<AuIO::IAsyncTransaction> {};
} }
AuSPtr<IO::IIOHandle> ProcessImpl::GetOutputAndInputHandles()
{
return this->fsHandle_;
}
AuSPtr<IO::IIOHandle> ProcessImpl::GetErrorStreamHandle()
{
return this->fsErrorHandle_;
}
void ProcessImpl::ForkMain() void ProcessImpl::ForkMain()
{ {
{ {

View File

@ -46,6 +46,8 @@ namespace Aurora::Processes
AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() override; AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() override;
AuSPtr<IO::IAsyncTransaction> NewErrorStreamAsyncTransaction() override; AuSPtr<IO::IAsyncTransaction> NewErrorStreamAsyncTransaction() override;
AuSPtr<IO::IIOHandle> GetOutputAndInputHandles() override;
AuSPtr<IO::IIOHandle> GetErrorStreamHandle() override;
bool Start() override; bool Start() override;