Unify watcher as sole execution backend#306
Open
ZnPdCo wants to merge 32 commits into
Open
Conversation
- watcher_unix.cpp: add argv[12]=workdir, argv[13]=extraTimeMs; parent uses SIGALRM + wait4 EINTR for wall clock timeout; child dispatches to execTarget - watcher_linux.cpp: add execTarget (bubblewrap sandbox) - watcher_macos.mm: add execTarget (direct bash execution) - processrunner_unix.cpp: unify Linux/macOS paths, remove bwrap construction and polling loop, add 2 new args - test scripts: update to pass D:\Project_LemonLime and 0 for new args; tle/redirect replaced manual kill with wait
When bwrap wraps the user program, RLIMIT signals go to the inner process (bash → user_prog), not to bwrap itself. bwrap/bash then exit with a non-zero exit code that encoded the signal termination. The parent previously checked exit code FIRST and returned RS_RE, masking the actual TLE/MLE. Swap the order: check limits first.
…it4 rusage bwrap calls wait4(child, &status, 0, NULL) with NULL rusage, so the user program's CPU time is NOT accumulated into bwrap's rusage. timeUsedMs from wait4(bwrap_pid) is just bwrap's own time (~0ms), making limit-vs-exit-code reordering insufficient. When bash's child is killed by a signal, bash exits with 128+signal. bwrap propagates this exit code to the watcher. Decode the exit code to detect which signal terminated the process, then report TLE (SIGXCPU) or MLE (SIGKILL/SIGABRT) accordingly. This works for both bwrap and direct execution.
bwrap 内部还有一层 fork,会导致无法正确获取 usage,为了减少麻烦,在执行 watcher 之前先进行一次 bwrap 自己。 为什么不在 qt 层面直接 bwrap:这次重构的一个目标是将主动权交由 watcher,watcher 应当拥有高权限。
ZnPdCo
marked this pull request as draft
July 13, 2026 09:42
ZnPdCo
marked this pull request as ready for review
July 16, 2026 08:40
ZnPdCo
commented
Jul 23, 2026
Contributor
Author
|
引入这个更改后是不是不再支持ubuntu18.04了 |
Contributor
Author
|
Linux Mint 19.3、Deepin 15.11、Debian 10.3.0、openSUSE 15.1 似乎 linux 内核版本都没达到(AI 说的),都不支持 |
Member
|
不要紧,支持 NOI Linux 2 就可以。比 NOI Linux 2 低的都可以扔掉。 |
Contributor
Author
|
ptal, thx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这个 pr 做了什么
正如 #302 中提到的,本 pr 将 watcher 统一为唯一的执行后端,移动 processrunner 中的部分逻辑到 watcher 中。
在执行 watcher 前,如果是 linux,会先进行一次 bwrap self-exec,并在执行 fork 前会设定一个定时器,以监控 wall time。其余部分大致相同。
同时添加对子进程数量的限制。