[*] Linux builds again. Still behind

This commit is contained in:
Reece Wilson 2022-06-23 13:25:20 +01:00
parent 3a76aa6d69
commit bf6f13095c
7 changed files with 69 additions and 44 deletions

View File

@ -67,12 +67,12 @@ namespace Aurora::Async
AUKN_SYM IAsyncApp *GetAsyncApp()
{
return gAsyncApp;
return gAsyncAppMem.get();
}
AUKN_SYM AuSPtr<IAsyncApp> GetSharedAsyncApp()
{
return AuUnsafeRaiiToShared(gAsyncApp);
return gAsyncAppMem;
}
bool AsyncApp::Spawn(WorkerId_t workerId)

View File

@ -945,7 +945,7 @@ namespace Aurora::Async
threadState->running = AuThreadPrimitives::EventUnique(true, false, true);
threadState->syncSema = AuThreadPrimitives::SemaphoreUnique(0);
threadState->id = workerId;
threadState->asyncLoop = AuMakeShared<AsyncLoop>();
threadState->asyncLoop = AuStaticCast<AsyncLoop>(AuLoop::NewLoopQueue());
threadState->rateLimiter.SetNextStep(1'000'000); // 1MS in nanoseconds
threadState->runMode = ERunMode::eEfficient;

View File

@ -24,12 +24,14 @@ namespace Aurora::Console::ConsoleTTY
void BeginBuffering()
{
return;
ConsoleStd::Lock();
gIsBuffering = true;
}
bool EndBuffering()
{
return true;
ConsoleStd::Unlock();
gIsBuffering = false;
//TODO (Reece): Was signal handler called?
@ -241,7 +243,7 @@ namespace Aurora::Console::ConsoleTTY
AUKN_SYM void TTYSetPos(AuPair<AuUInt32, AuUInt32> position)
{
TTYWrite(fmt::format("\033[{:1};{:0}H", position.first + 1, position.second + 1));
TTYWrite(fmt::format("\033[{:1};{:0}H", position.second + 1, position.first + 1));
}
AUKN_SYM void TTYScrollBuffer(int Y)

View File

@ -7,7 +7,7 @@
***/
#pragma once
namespace Aurora::Console
namespace Aurora::Console::ConsoleTTY
{
bool IsBuffering();
void BeginBuffering();

View File

@ -1711,7 +1711,8 @@ namespace Aurora::Console::ConsoleTTY
bool TTYConsole::NoncanonicalMode()
{
return true;// false;
// TOOD: wrong
return AuBuild::kCurrentPlatform == AuBuild::EPlatform::ePlatformWin32;
}

View File

@ -108,12 +108,29 @@ namespace Aurora::Processes
void ProcessImpl::ShutdownPipes()
{
//if (auto fd = AuExchange(pipeStdErr_[0], {})) close(fd); // ME
if (auto fd = AuExchange(pipeStdErr_[1], {})) close(fd);
//if (auto fd = AuExchange(pipeStdOut_[0], {})) close(fd); // ME
if (auto fd = AuExchange(pipeStdOut_[1], {})) close(fd);
if (auto fd = AuExchange(pipeStdIn_[0], {})) close(fd);
//if (auto fd = AuExchange(pipeStdIn_[1], {})) close(fd); // ME
if (!this->bDontRelOut_)
{
if (auto fd = AuExchange(pipeStdOut_[1], {}))
{
::close(fd);
}
}
if (!this->bDontRelErr_)
{
if (auto fd = AuExchange(pipeStdErr_[1], {}))
{
::close(fd);
}
}
if (!this->bDontRelIn_)
{
if (auto fd = AuExchange(pipeStdIn_[0], {}))
{
::close(fd);
}
}
}
bool ProcessImpl::TryKill()
@ -235,34 +252,34 @@ namespace Aurora::Processes
return ::write(handle, source.ptr, source.length) == source.length;
}
static bool InitProcessStdHandles(EStreamForward fwd, int *fds)
{
switch (fwd)
{
case EStreamForward::eCurrentProcess:
// Intentionally NO-OP
break;
case EStreamForward::eAsyncPipe:
if (::pipe(fds))
{
SysPushErrorMem();
return false;
}
break;
case EStreamForward::eNull:
fds[0] = ::open("/dev/null", O_RDWR);
fds[1] = ::open("/dev/null", O_RDWR);
break;
}
return true;
}
bool ProcessImpl::Init()
{
if (this->startup_.fwdOut)
{
if (::pipe(this->pipeStdOut_))
{
SysPushErrorMem();
return false;
}
}
if (this->startup_.fwdErr)
{
if (::pipe(this->pipeStdErr_))
{
SysPushErrorMem();
return false;
}
}
if (this->startup_.fwdIn)
{
if (::pipe(this->pipeStdIn_))
{
SysPushErrorMem();
return false;
}
}
InitProcessStdHandles(this->startup_.fwdOut, this->pipeStdOut_);
InitProcessStdHandles(this->startup_.fwdErr, this->pipeStdErr_);
InitProcessStdHandles(this->startup_.fwdIn, this->pipeStdIn_);
this->loopSource_ = AuMakeShared<ProcessAliveLoopSource>();
if (!this->loopSource_)
@ -277,7 +294,8 @@ namespace Aurora::Processes
return false;
}
if (this->startup_.fwdIn || this->startup_.fwdOut)
if ((this->startup_.fwdIn == EStreamForward::eAsyncPipe) ||
(this->startup_.fwdOut == EStreamForward::eAsyncPipe))
{
this->fsHandle_ = AuMakeShared<IO::FS::FileHandle>();
if (!this->fsHandle_)
@ -295,7 +313,7 @@ namespace Aurora::Processes
this->fsStream_->Init(this->fsHandle_);
}
if (this->startup_.fwdErr)
if (this->startup_.fwdErr == EStreamForward::eAsyncPipe)
{
this->fsErrorHandle_ = AuMakeShared<IO::FS::FileHandle>();
if (!this->fsErrorHandle_)
@ -344,7 +362,7 @@ namespace Aurora::Processes
if (pid == 0)
{
if (this->startup_.fwdIn)
if (this->startup_.fwdIn != EStreamForward::eCurrentProcess)
{
::dup2(pipeStdIn_[0], STDIN_FILENO);
@ -352,14 +370,14 @@ namespace Aurora::Processes
::close(pipeStdIn_[1]);
}
if (this->startup_.fwdErr)
if (this->startup_.fwdErr != EStreamForward::eCurrentProcess)
{
::dup2(pipeStdErr_[1], STDERR_FILENO);
::close(pipeStdErr_[0]);
::close(pipeStdErr_[1]);
}
if (this->startup_.fwdOut)
if (this->startup_.fwdOut != EStreamForward::eCurrentProcess)
{
::dup2(pipeStdOut_[1], STDOUT_FILENO);
::close(pipeStdOut_[0]);
@ -398,7 +416,7 @@ namespace Aurora::Processes
this->alive_ = true;
{
AU_LOCK_GUARD(gRWLock->AsWritable());\
AU_LOCK_GUARD(gRWLock->AsWritable());
SysAssert(AuTryInsert(gPidLookupMap, pid, this));
}

View File

@ -58,6 +58,10 @@ namespace Aurora::Processes
int pipeStdErr_[2]{};
int pipeStdIn_ [2]{};
bool bDontRelOut_ {};
bool bDontRelIn_ {};
bool bDontRelErr_ {};
AuSPtr<IO::Loop::ILSEvent> loopSource_;
AuSPtr<IO::FS::FileHandle> fsHandle_;