Skip to content

Commit

Permalink
fix(judge): no bwrap in macos
Browse files Browse the repository at this point in the history
  • Loading branch information
alphagocc committed Jun 23, 2024
1 parent 2c0c98f commit f4db375
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion makespec/BUILDVERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
263
264
33 changes: 33 additions & 0 deletions src/core/judgingthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,8 @@ void JudgingThread::runProgram() {
LOG("User Time Used:", timeUsed, "ms, Kernel Time Used:", kernelTimeUsed,
"ms, User+Kernel Time Used:", timeUsed + kernelTimeUsed, "ms, Memory Used:", memoryUsed, "bytes");
#else

#ifdef Q_OS_LINUX
// TODO: rewrite with cgroup
QFile watcher(workingDirectory + QUuid::createUuid().toString(QUuid::Id128));
QFile::copy(":/watcher/watcher_unix", watcher.fileName());
Expand Down Expand Up @@ -941,6 +943,37 @@ void JudgingThread::runProgram() {
runner->setWorkingDirectory(workingDirectory);
runner->start("/usr/bin/bwrap", argumentsList);

#else

QFile watcher(workingDirectory + QUuid::createUuid().toString(QUuid::Id128));
QFile::copy(":/watcher/watcher_unix", watcher.fileName());
watcher.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner);
auto *runner = new QProcess(this);
QStringList argumentsList;
argumentsList << QString("\"%1\" %2").arg(executableFile, arguments);

if (task->getStandardInputCheck()) {
argumentsList << QFileInfo(inputFile).absoluteFilePath();
} else {
argumentsList << "";
}

if (task->getStandardOutputCheck()) {
argumentsList << "_tmpout";
} else {
argumentsList << "";
}

argumentsList << "_tmperr";
argumentsList << QString("%1").arg(timeLimit + extraTime);
argumentsList << QString("%1").arg(memoryLimit);

runner->setProcessEnvironment(environment);
runner->setWorkingDirectory(workingDirectory);
runner->start(watcher.fileName(), argumentsList);

#endif

if (! runner->waitForStarted(-1)) {
delete runner;
score = 0;
Expand Down

0 comments on commit f4db375

Please sign in to comment.