[*] PosixShutup for AuProcesses::OpenXXXX and two minor bug fixes

This commit is contained in:
Reece Wilson 2024-03-15 06:18:32 +00:00
parent b3f1ef8bc2
commit ccc4116394
7 changed files with 63 additions and 16 deletions

View File

@ -16,15 +16,32 @@ namespace Aurora::Process
namespace Aurora
{
int PosixOpen(const char *pathname, int flags, mode_t mode)
{
return ::open(pathname, flags, mode);
}
void PosixDoForkHooks()
{
Process::PosixForkResetLocks();
Debug::DeinitSignalHandlers();
}
void PosixShutup()
{
int fd = PosixOpen("/dev/null", O_RDWR);
::dup2(fd, STDERR_FILENO);
::dup2(fd, STDOUT_FILENO);
::dup2(fd, STDIN_FILENO);
::close(fd);
}
void PosixTerminate()
{
killpg(0, SIGKILL);
#if 0
PosixShutup();
#endif
::killpg(0, SIGKILL);
}
static bool PosixLseek63(int fd, AuUInt64 offset, int whence, AuUInt64 *pOffset)

View File

@ -7,10 +7,16 @@
***/
#pragma once
// PosixOpen platform specific flags!
#include <fcntl.h>
namespace Aurora
{
void PosixDoForkHooks();
void PosixTerminate();
void PosixDoForkHooks();
void PosixShutup();
void PosixTerminate();
int PosixOpen(const char *pathname, int flags, mode_t mode = 0);
AuUInt64 PosixGetOffset(int fd);
bool PosixSetOffset(int fd, AuUInt64 offset);

View File

@ -128,7 +128,7 @@ namespace Aurora::HWInfo
dUsage[i] = AuMax(this->dPrevLoad[i] / 2.0, 0.0001);
}
}
else if (!dUsage)
else if (!dUsage[i])
{
dUsage[i] = AuMax(this->dPrevLoad[i] / 2.0, 0.0001);
}

View File

@ -191,9 +191,9 @@ namespace Aurora::IO
// TBD
#endif
iFileDescriptor = ::open(pathex.c_str(),
flags,
0664);
iFileDescriptor = PosixOpen(pathex.c_str(),
flags,
0664);
if (iFileDescriptor < 0)
{
@ -211,9 +211,9 @@ namespace Aurora::IO
{
RuntimeWaitForSecondaryTick();
iFileDescriptor = ::open(pathex.c_str(),
flags,
0664);
iFileDescriptor = PosixOpen(pathex.c_str(),
flags,
0664);
}
if (iFileDescriptor < 0)
@ -227,9 +227,9 @@ namespace Aurora::IO
if (errno == EISDIR)
{
flags &= ~(O_WRONLY | O_RDWR);
iFileDescriptor = ::open(pathex.c_str(),
flags,
0664);
iFileDescriptor = PosixOpen(pathex.c_str(),
flags,
0664);
}
if (iFileDescriptor < 0)

View File

@ -527,6 +527,19 @@ namespace Aurora::IO::FS
}
}
}
else
{
if (bUseResult)
{
out->errorTraversePaths.push_back(rawPath);
}
else
{
SysPushErrorIO("failed to copy dir: {}", rawPath);
}
continue;
}
AuList<AuString> dirs;
if (AuFS::DirsInDirectory(rawPath, dirs))
@ -542,6 +555,10 @@ namespace Aurora::IO::FS
{
out->errorTraversePaths.push_back(rawPath);
}
else
{
SysPushErrorIO("failed to copy dir: {}", rawPath);
}
}
}
}
@ -629,6 +646,10 @@ namespace Aurora::IO::FS
{
out->errorTraversePaths.push_back(rawPath);
}
else
{
SysPushErrorIO("failed to move dir: {}", rawPath);
}
}
}
}
@ -658,7 +679,8 @@ namespace Aurora::IO::FS
for (const auto &dir : dirsAll)
{
if (AuFS::DirExists(dir))
if (AuFS::DirExists(dir) &&
!AuExists(out->errorTraversePaths, dir))
{
out->errorTraversePaths.push_back(dir);
}

View File

@ -62,6 +62,8 @@ namespace Aurora::Processes
PosixDoForkHooks();
PosixShutup();
auto optStringA = AuProcess::EnvironmentGetOne("container");
auto optStringB = AuProcess::EnvironmentGetOne("AURORA_RUNTIME_USE_GDBUS_BIN_TO_PORTAL");
bool bIsFireJail = optStringA && optStringA.Value() == "firejail";

View File

@ -392,11 +392,11 @@ namespace Aurora::Processes
case EStreamForward::eNull:
if (bIsRead)
{
fds[0] = ::open("/dev/null", O_RDWR);
fds[0] = PosixOpen("/dev/null", O_RDWR);
}
else
{
fds[1] = ::open("/dev/null", O_RDWR);
fds[1] = PosixOpen("/dev/null", O_RDWR);
}
break;
case EStreamForward::eNewConsoleWindow: