MCPcopy Create free account
hub / github.com/Project-LemonLime/Project_LemonLime / run

Method run

src/core/processrunner_unix.cpp:29–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27#define LEMON_MODULE_NAME "ProcessRunner"
28
29ProcessRunnerResult UnixProcessRunner::run() {
30 ProcessRunnerResult res;
31 res.result = CorrectAnswer;
32 int extraTime = qCeil(qMax(2000, config.timeLimit * 2) * config.extraTimeRatio);
33
34#ifdef Q_OS_LINUX
35 // TODO: rewrite with cgroup
36 QFile watcher(config.workingDirectory + QUuid::createUuid().toString(QUuid::Id128));
37
38 if (config.interpreterAsWatcher) {
39 QFile::copy(config.executableFile, watcher.fileName());
40 } else {
41 QFile::copy(":/watcher/watcher_unix", watcher.fileName());
42 }
43
44 watcher.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner);
45 auto *runner = new QProcess();
46 QStringList argumentsList;
47
48 argumentsList << "--dev" << "/dev";
49 argumentsList << "--proc" << "/proc";
50 argumentsList << "--ro-bind" << "/usr" << "/usr";
51 argumentsList << "--symlink" << "/usr/lib" << "/lib";
52 argumentsList << "--symlink" << "/usr/lib64" << "/lib64";
53 argumentsList << "--symlink" << "/usr/bin" << "/bin";
54 argumentsList << "--symlink" << "/usr/sbin" << "/sbin";
55 argumentsList << "--tmpfs" << "/tmp";
56
57 argumentsList << "--unshare-all" << "--die-with-parent";
58
59 argumentsList << "--chdir" << config.workingDirectory;
60
61 argumentsList << "--bind" << config.workingDirectory << config.workingDirectory;
62
63 if (config.standardInputCheck) {
64 argumentsList << "--ro-bind" << QFileInfo(config.inputFile).absoluteFilePath()
65 << QFileInfo(config.inputFile).absoluteFilePath();
66 }
67
68 argumentsList << watcher.fileName();
69
70 argumentsList << config.executableFile;
71 argumentsList << config.arguments;
72
73 if (config.standardInputCheck) {
74 argumentsList << QFileInfo(config.inputFile).absoluteFilePath();
75 } else {
76 argumentsList << "";
77 }
78
79 if (config.standardOutputCheck) {
80 argumentsList << "_tmpout";
81 } else {
82 argumentsList << "";
83 }
84
85 argumentsList << "_tmperr";
86 argumentsList << QString("%1").arg(config.timeLimit);

Callers

nothing calls this directly

Calls 3

setProcessEnvironmentMethod · 0.80
setWorkingDirectoryMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected