Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Documentation/locale/en/LC_MESSAGES/userspace-api/abi.po
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,33 @@ msgstr ""
"headers; SQLite uses standard ``libsqlite3.so.0`` POSIX VFS. Historical ABI snapshots stay "
"unchanged, and compatibility checks continue covering first-party interfaces."

msgid "带进程文件描述符的快照"
msgstr "Snapshots with process file descriptors"

msgid ""
"``<reliefos/system.h>`` 中的 ``reliefos_task_snapshot_pidfds()`` 和原有 "
"``reliefos_task_snapshot()`` 使用相同的进程记录和时间戳约定。调用者为 ``tasks`` 和 ``pidfds`` "
"各提供至少 ``capacity`` 个元素;成功返回的行数同时 适用于两个数组。每一行的 ``pidfds`` 值是带 "
"``FD_CLOEXEC`` 的独立描述符, 或在无法取得稳定描述符时为 ``-1``。调用者负责关闭返回范围内的所有非负值。"
msgstr ""
"``reliefos_task_snapshot_pidfds()`` in ``<reliefos/system.h>`` uses the "
"same process records and timestamp conventions as "
"``reliefos_task_snapshot()``. Provide at least ``capacity`` elements in "
"each of ``tasks`` and ``pidfds``. On success, the returned row count "
"applies to both arrays. Each entry in ``pidfds`` is a separate descriptor"
" with ``FD_CLOEXEC``, or ``-1`` if a stable descriptor is unavailable. "
"The caller must close every nonnegative descriptor in the returned range."

msgid ""
"任务管理器用描述符绑定选中的进程。打开结束任务确认框时,它复制该描述符, 不因列表刷新改变目标;如果进程已退出或描述符不可用,不退回按数字 PID"
" 发送信号。"
msgstr ""
"Task Manager identifies the selected process by its descriptor. It "
"duplicates the descriptor before opening the End Task confirmation, so "
"refreshing the list cannot change the target. If the process has exited "
"or no descriptor is available, Task Manager does not fall back to "
"signaling a numeric PID."

msgid "按任务选择 uname 系统名"
msgstr "Selecting the uname system name per task"

Expand Down
23 changes: 23 additions & 0 deletions Documentation/locale/ja/LC_MESSAGES/userspace-api/abi.po
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,29 @@ msgstr ""
"VFS は安定した互換 API ではありません。実装詳細に依存するプログラムは SDK の対応ヘッダーで再コンパイルする必要があります。SQLite は標準 ``libsqlite3.so.0``"
" の POSIX VFS を使います。過去の ABI スナップショットは保持し、互換性検査は引き続き第一者の API を対象にします。"

msgid "带进程文件描述符的快照"
msgstr "プロセスファイルディスクリプター付きのスナップショット"

msgid ""
"``<reliefos/system.h>`` 中的 ``reliefos_task_snapshot_pidfds()`` 和原有 "
"``reliefos_task_snapshot()`` 使用相同的进程记录和时间戳约定。调用者为 ``tasks`` 和 ``pidfds`` "
"各提供至少 ``capacity`` 个元素;成功返回的行数同时 适用于两个数组。每一行的 ``pidfds`` 值是带 "
"``FD_CLOEXEC`` 的独立描述符, 或在无法取得稳定描述符时为 ``-1``。调用者负责关闭返回范围内的所有非负值。"
msgstr ""
"``<reliefos/system.h>`` の ``reliefos_task_snapshot_pidfds()`` は、既存の "
"``reliefos_task_snapshot()`` と同じプロセスレコードとタイムスタンプの規約を使用します。呼び出し側は "
"``tasks`` と ``pidfds`` にそれぞれ ``capacity`` "
"個以上の要素を用意します。成功時の戻り値は両方の配列に共通する行数です。``pidfds`` の各要素は ``FD_CLOEXEC`` "
"付きの個別のディスクリプター、または安定したディスクリプターを取得できない場合は ``-1`` です。返された範囲の 0 "
"以上のディスクリプターはすべて呼び出し側で閉じてください。"

msgid ""
"任务管理器用描述符绑定选中的进程。打开结束任务确认框时,它复制该描述符, 不因列表刷新改变目标;如果进程已退出或描述符不可用,不退回按数字 PID"
" 发送信号。"
msgstr ""
"タスクマネージャーは、選択したプロセスをディスクリプターで識別します。タスクの終了を確認するダイアログを開く前にディスクリプターを複製するため、一覧が更新されても対象は変わりません。プロセスが終了済みの場合やディスクリプターが取得できない場合に、数値"
" PID を使ってシグナルを送信することはありません。"

msgid "按任务选择 uname 系统名"
msgstr "タスクごとの uname システム名の選択"

Expand Down
12 changes: 12 additions & 0 deletions Documentation/userspace-api/abi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ vDSO 提供已实现的时间接口,失败或不支持的时钟保留 syscall

X11 应用通过 Xorg 通信。未知或旧兼容路径不能当作新的公开接口。

带进程文件描述符的快照
----------------------

``<reliefos/system.h>`` 中的 ``reliefos_task_snapshot_pidfds()`` 和原有
``reliefos_task_snapshot()`` 使用相同的进程记录和时间戳约定。调用者为
``tasks`` 和 ``pidfds`` 各提供至少 ``capacity`` 个元素;成功返回的行数同时
适用于两个数组。每一行的 ``pidfds`` 值是带 ``FD_CLOEXEC`` 的独立描述符,
或在无法取得稳定描述符时为 ``-1``。调用者负责关闭返回范围内的所有非负值。

任务管理器用描述符绑定选中的进程。打开结束任务确认框时,它复制该描述符,
不因列表刷新改变目标;如果进程已退出或描述符不可用,不退回按数字 PID 发送信号。

按任务选择 uname 系统名
========================

Expand Down
10 changes: 8 additions & 2 deletions configs/nls/po/taskmgr/ja_JP.po
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,14 @@ msgid "Task Manager"
msgstr "タスクマネージャー"

#: userland/apps/taskmgr/main.cpp:575
msgid "Task ended"
msgstr "タスクを終了しました"
msgid "Termination signal sent."
msgstr "終了シグナルを送信しました。"

msgid "A stable handle for this process is unavailable."
msgstr "このプロセスの安定したハンドルを取得できません。"

msgid "The selected process has already exited."
msgstr "選択したプロセスは既に終了しています。"

#: userland/apps/taskmgr/main.cpp:482
msgid "Tasks "
Expand Down
8 changes: 7 additions & 1 deletion configs/nls/po/taskmgr/taskmgr.pot
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,13 @@ msgid "Task Manager"
msgstr ""

#: userland/apps/taskmgr/main.cpp:575
msgid "Task ended"
msgid "Termination signal sent."
msgstr ""

msgid "A stable handle for this process is unavailable."
msgstr ""

msgid "The selected process has already exited."
msgstr ""

#: userland/apps/taskmgr/main.cpp:482
Expand Down
10 changes: 8 additions & 2 deletions configs/nls/po/taskmgr/zh_CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,14 @@ msgid "Task Manager"
msgstr "任务管理器"

#: userland/apps/taskmgr/main.cpp:575
msgid "Task ended"
msgstr "任务已结束"
msgid "Termination signal sent."
msgstr "已发送终止信号。"

msgid "A stable handle for this process is unavailable."
msgstr "无法获取此进程的稳定句柄。"

msgid "The selected process has already exited."
msgstr "选中的进程已退出。"

#: userland/apps/taskmgr/main.cpp:482
msgid "Tasks "
Expand Down
4 changes: 4 additions & 0 deletions include/reliefos/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ struct reliefos_task_snapshot {

unsigned long reliefos_uptime_ms(void);
int reliefos_task_snapshot(struct reliefos_task_info *tasks, uint32_t capacity, uint64_t *tick);
/* Like task_snapshot, with one owned close-on-exec pidfd (or -1 when
* unavailable) per returned row. Caller closes every nonnegative entry. */
int reliefos_task_snapshot_pidfds(struct reliefos_task_info *tasks, int *pidfds,
uint32_t capacity, uint64_t *tick);
int reliefos_task_kill(uint32_t pid);

#endif
2 changes: 1 addition & 1 deletion kernel/reliefnt
Submodule reliefnt updated 50 files
+12 −0 Documentation/locale/en/LC_MESSAGES/process/testing.po
+101 −0 Documentation/locale/en/LC_MESSAGES/userspace-api/pidfd.po
+10 −0 Documentation/locale/ja/LC_MESSAGES/process/testing.po
+90 −0 Documentation/locale/ja/LC_MESSAGES/userspace-api/pidfd.po
+5 −0 Documentation/process/testing.rst
+1 −0 Documentation/userspace-api/index.rst
+37 −0 Documentation/userspace-api/pidfd.rst
+2 −0 configs/header-export.list
+6 −1 fs/proc/views.c
+39 −0 include/reliefnt/pidfd.h
+8 −3 include/reliefnt/proc_stats.h
+20 −0 include/reliefnt/sched.h
+29 −1 include/reliefnt/signal.h
+29 −0 include/reliefnt/task/accessors.h
+4 −0 include/reliefnt/task/types.h
+13 −0 include/uapi/linux/pidfd.h
+20 −0 include/uapi/linux/wait.h
+49 −9 kernel/sched/accounting.c
+1 −0 kernel/sched/clone.c
+54 −1 kernel/sched/identity.c
+18 −0 kernel/sched/internal.h
+15 −1 kernel/sched/signal.c
+58 −8 kernel/sched/task.c
+83 −10 kernel/sched/wait.c
+55 −27 kernel/signal/signal_queue.c
+9 −0 kernel/syscall/dispatch.c
+6 −1 kernel/syscall/entry.c
+3 −0 kernel/syscall/event/poll.c
+2 −0 kernel/syscall/fd/descriptor.c
+3 −1 kernel/syscall/fd/legacy_descriptors.c
+10 −0 kernel/syscall/fd/proc.c
+5 −0 kernel/syscall/fs/stat.c
+3 −1 kernel/syscall/io/io.c
+3 −1 kernel/syscall/io/legacy_io.c
+1 −0 kernel/syscall/io/vector.c
+1 −1 kernel/syscall/process/Kbuild
+9 −6 kernel/syscall/process/legacy_process.c
+186 −0 kernel/syscall/process/pidfd.c
+1 −1 tools/test_exit_logging.py
+1 −0 tools/test_poll_wakeup.py
+1 −0 tools/tests/memory_pressure_wait_test.c
+402 −0 tools/tests/pidfd_probe.c
+9 −0 tools/tests/poll_wakeup_test.c
+4 −0 tools/tests/task8_host_fixtures.json
+6 −2 tools/tests/task8_host_stubs/fix1-wait-frame-unreached.c
+7 −4 tools/tests/task8_wait_frame_test.c
+53 −2 tools/tests/task8_wait_swap_test.c
+74 −0 tools/tests/task_exit_logging_test.c
+21 −1 tools/tests/task_identity_test.c
+1 −0 tools/tests/user_return_gate_test.c
64 changes: 58 additions & 6 deletions tools/tests/procsys_status_test.c
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
#define _POSIX_C_SOURCE 200809L
#define _GNU_SOURCE
#include <assert.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <sys/poll.h>
#include <unistd.h>
#include <reliefos/fs.h>
int fixture_open(const char *path, int flags, ...);
int fixture_openat(int dir, const char *path, int flags, ...);
long fixture_syscall(long number, ...);
int fixture_poll(struct pollfd *fds, nfds_t count, int timeout);
ssize_t fixture_read(int fd, void *buffer, size_t size);
int fixture_close(int fd);
int fixture_readdir(int fd, struct reliefos_dir_entry *entry);
int fixture_getpwuid_r(uid_t uid, struct passwd *record, char *buffer, size_t size,
struct passwd **result);
#define open fixture_open
#define openat fixture_openat
#define syscall fixture_syscall
#define poll fixture_poll
#define read fixture_read
#define close fixture_close
#define getpwuid_r fixture_getpwuid_r
#define reliefos_readdir fixture_readdir
#include "../../userland/runtime/src/procsys.c"
#undef open
#undef openat
#undef syscall
#undef poll
#undef read
#undef close
#undef getpwuid_r
#undef reliefos_readdir

static unsigned cursor, offset, closes;
static int current_file, missing_status;
uint64_t reliefos_uptime_ms(void) { return 123; }
#include <stdarg.h>

static unsigned cursor, offset, closes, handle_closes;
static int current_file, missing_status, pidfd_missing, exited_after_read;
int fixture_open(const char *path, int flags, ...)
{
(void)flags;
Expand All @@ -37,6 +48,30 @@ int fixture_open(const char *path, int flags, ...)
current_file = 2;
return missing_status ? -1 : 1;
}
int fixture_openat(int dir, const char *path, int flags, ...)
{
(void)flags;
if (dir == 0) { assert(!strcmp(path, "42")); return 2; }
assert(dir == 2);
if (!strcmp(path, "stat")) return fixture_open("/proc/42/stat", flags);
assert(!strcmp(path, "status"));
return fixture_open("/proc/42/status", flags);
}
long fixture_syscall(long number, ...)
{
va_list args;
va_start(args, number);
assert(number == SYS_pidfd_open && va_arg(args, long) == 42L && va_arg(args, long) == 0L);
va_end(args);
if (pidfd_missing) { errno = ENOSYS; return -1; }
return 7;
}
int fixture_poll(struct pollfd *fds, nfds_t count, int timeout)
{
assert(count == 1 && timeout == 0 && fds->fd == 7 && fds->events == POLLIN);
fds->revents = exited_after_read ? POLLIN | POLLHUP : 0;
return !!fds->revents;
}
ssize_t fixture_read(int fd, void *buffer, size_t size)
{
assert(fd == 1);
Expand All @@ -48,7 +83,13 @@ ssize_t fixture_read(int fd, void *buffer, size_t size)
memcpy(buffer, text + offset, length); offset += length;
return length;
}
int fixture_close(int fd) { assert(fd == 0 || fd == 1); ++closes; return 0; }
int fixture_close(int fd)
{
assert(fd == 0 || fd == 1 || fd == 2 || fd == 7);
if (fd == 7) ++handle_closes;
++closes;
return 0;
}
int fixture_readdir(int fd, struct reliefos_dir_entry *entry)
{
assert(fd == 0);
Expand All @@ -72,5 +113,16 @@ int main(void)
missing_status = 1;
assert(reliefos_task_snapshot(&task, 1, NULL) == 1);
assert(task.uid == UINT32_MAX && task.memory_kib == 0 && closes == 5);
puts("PASS task snapshot: status UID/RSS, account resolution, partial reads and fd cleanup");
missing_status = 0;
int fd = -1;
assert(reliefos_task_snapshot_pidfds(&task, &fd, 1, NULL) == 1);
assert(fd == 7 && task.pid == 42 && task.uid == 1001 && handle_closes == 0);
assert(fixture_close(fd) == 0);
exited_after_read = 1;
assert(reliefos_task_snapshot_pidfds(&task, &fd, 1, NULL) == 0);
assert(handle_closes == 2);
pidfd_missing = 1;
assert(reliefos_task_snapshot_pidfds(&task, &fd, 1, NULL) == 1);
assert(fd == -1 && task.pid == 42 && handle_closes == 2);
puts("PASS task snapshot: metadata, pidfd ownership, discarded stale row and old-kernel fallback");
}
Loading