Skip to content

feat: add select and pselect6 syscall #1229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Godones
Copy link
Member

@Godones Godones commented Jul 6, 2025

WARN: 测试程序无法运行!!! 子进程会出现页错误

@github-actions github-actions bot added the enhancement New feature or request label Jul 6, 2025
@Godones Godones requested a review from Copilot July 6, 2025 09:29
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements new select and pselect6 syscalls in the kernel, adds a user-space test application for select, and exposes poll utilities required by the new syscalls.

  • Introduce a simple select test program and its DADK build configuration
  • Implement SysSelect and SysPselect6 kernel handlers and register them
  • Expose do_sys_poll and poll_select_set_timeout as public helpers and enable the let_chains feature

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
user/dadk/config/test_select_0_1_1.toml Add DADK config for the test_select application
user/apps/test_select/main.c Add user-space select demo utilizing eventfd
user/apps/test_select/Makefile Add build/install/clean targets for test_select
kernel/src/lib.rs Enable let_chains nightly feature for Rust patterns
kernel/src/filesystem/vfs/syscall/sys_select.rs Implement select syscall and its helper functions
kernel/src/filesystem/vfs/syscall/sys_pselect6.rs Implement pselect6 syscall wrapper
kernel/src/filesystem/vfs/syscall/mod.rs Register the new syscall modules
kernel/src/filesystem/poll.rs Make do_sys_poll and poll_select_set_timeout public
Comments suppressed due to low confidence (2)

kernel/src/filesystem/vfs/syscall/sys_select.rs:62

  • The call to size_of::<PosixTimeval>() requires an import of core::mem::size_of; add use core::mem::size_of; at the top to avoid an unresolved name error.
            size_of::<PosixTimeval>(),

kernel/src/filesystem/vfs/syscall/sys_pselect6.rs:30

  • The call to size_of::<SigSet>() also needs use core::mem::size_of; imported to compile.
                UserBufferReader::new(sigmask_ptr as *const SigSet, size_of::<SigSet>(), true)?;

@fslongjin
Copy link
Member

fslongjin commented Jul 7, 2025

WARN: 测试程序无法运行!!! 子进程会出现页错误

2025.7.10更新

是进程拷贝信号处理程序的bug。busybox启动的时候设置了SIGCHLD的处理函数。结果fork的时候子进程错误的继承了这个值。但是其实子进程没这个信号处理函数。导致收到SIGCHLD信号的时候崩溃。
image

image image

(原始评论)

可能跟进程fork&退出的时候unmap页面/pagecache有关?
cc @sparkzky @MemoryShore
只要我不让子进程退出就不会出现segment fault,以及No mapped VMA的报错。

image

@sparkzky
Copy link
Collaborator

WARN: 测试程序无法运行!!! 子进程会出现页错误

2025.7.10更新

是进程拷贝信号处理程序的bug。busybox启动的时候设置了SIGCHLD的处理函数。结果fork的时候子进程错误的继承了这个值。但是其实子进程没这个信号处理函数。导致收到SIGCHLD信号的时候崩溃。 image

image image
(原始评论)

可能跟进程fork&退出的时候unmap页面/pagecache有关? cc @sparkzky @MemoryShore 只要我不让子进程退出就不会出现segment fault,以及No mapped VMA的报错。

image

好像这个信号处理函数还是有必要的?后面busybox一直在调用SYS_RT_SIGTIMEDWAIT好像就是没有接收到子进程的SIGCHLD信号?

image image

Godones added 2 commits July 12, 2025 23:14
Signed-off-by: Godones <chenlinfeng25@outlook.com>
Signed-off-by: Godones <chenlinfeng25@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants