Skip to content

syscall: Add pthread_sigqueue() to the system call table. - #21070

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
casaroli:pthread-sigqueue-syscall
Oct 28, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
casaroli:pthread-sigqueue-syscall

Conversation

@casaroli

Copy link
Copy Markdown
Contributor

Summary

pthread_sigqueue() is implemented in the kernel (sched/pthread/pthread_sigqueue.c), but it has no entry in the system call table: only libs/libc/libc.csv lists it. So in a protected or kernel build a user program that calls pthread_sigqueue() does not link. The CI of apache/nuttx-apps#3931 shows it: undefined reference to 'pthread_sigqueue' in nuttx_user.elf of smartl-c906:knsh.

This PR adds pthread_sigqueue to syscall/syscall.csv (in alphabetical order; the union sigval argument is passed as for sigqueue) and to include/sys/syscall_lookup.h, next to pthread_sigmask. It removes the libc.csv entry, because the function is not in libc. The condition is !defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_DISABLE_ALL_SIGNALS): pthread_sigqueue.c is built with pthreads, and it calls nxsig_dispatch(), which is built only with signals.

Impact

pthread_sigqueue() is available to user programs in protected and kernel builds. Adding a system call changes the numbers of the calls after it, as for any new system call; programs of a kernel build must be built again. Flat builds call the same function as before; the system symbol table now takes the entry from syscall.csv.

Testing

A test program (a thread waits in sigwaitinfo(); the main thread sends SIGUSR1 with pthread_sigqueue(), first with a sival_int, then with a sival_ptr, and then with signal 1000):

  • qemu-armv8a:knsh (kernel build, QEMU 11 with HVF on an Apple M4):
    • master: the program does not link (undefined references: pthread_sigqueue).
    • this PR: both signals arrive with si_code == SI_QUEUE and the sent value; signal 1000 gives EINVAL.
  • mps2-an500:knsh (protected build, QEMU TCG), this PR: the same output.
psqtest: send int ret=0
psqtest: send ptr ret=0
psqtest: badsig   PASS
psqtest: int      PASS
psqtest: ptr      PASS
psqtest: PASS

ostest on qemu-armv8a:knsh and qemu-armv8a:nsh ends with ostest_main: Exiting with status 0. With CONFIG_DISABLE_ALL_SIGNALS=y the generated STUB_pthread_sigqueue.c is under the same #if, so no stub is built (the full build of mps2-an500:knsh with that option fails on master too, in boards/arm/mps/mps2-an500/kernel/mps_userspace.c:113, for another reason). tools/checkpatch.sh -c -u -m -g passes.

pthread_sigqueue() is implemented in sched/pthread/pthread_sigqueue.c,
but it has no system call entry: only libs/libc/libc.csv lists it.  In a
protected or kernel build, user programs that call pthread_sigqueue()
fail to link.

Add it to syscall.csv and syscall_lookup.h, and remove the libc.csv
entry.  The condition also needs !CONFIG_DISABLE_ALL_SIGNALS, because
the implementation calls nxsig_dispatch(), which is built only with
signals.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
@github-actions github-actions Bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Oct 28, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@xiaoxiang781216
xiaoxiang781216 merged commit 52274fe into apache:master Oct 28, 2026
53 checks passed
Swatantra-66 added a commit to Swatantra-66/nuttx-apps that referenced this pull request Oct 29, 2026
Add automated unit test for pthread_sigqueue() in ostest to verify
signal and payload delivery to a target pthread. Tests error handling
for invalid signal numbers and non-existent thread IDs, as well as
successful signal dispatch and reception with SA_SIGINFO and SI_QUEUE.

Now that pthread_sigqueue() is implemented as a system call
(apache/nuttx#21070), the test runs across flat, protected, and
kernel builds.

Configurable via CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE, enabled by
default for non-small builds (!DEFAULT_SMALL) and gated by
ENABLE_ALL_SIGNALS and !DISABLE_PTHREAD. Progress output and error
messages are streamlined to minimize the flash footprint.

Signed-off-by: Swatantra Yadav <[email protected]>
Swatantra-66 added a commit to Swatantra-66/nuttx-apps that referenced this pull request Oct 30, 2026
Add automated unit test for pthread_sigqueue() in ostest to verify
signal and payload delivery to a target pthread. Tests error handling
for invalid signal numbers and non-existent thread IDs, as well as
successful signal dispatch and reception with SA_SIGINFO and SI_QUEUE.

Now that pthread_sigqueue() is implemented as a system call
(apache/nuttx#21070), the test runs across flat, protected, and
kernel builds.

Configurable via CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE, enabled by
default for non-small builds (!DEFAULT_SMALL) and gated by
ENABLE_ALL_SIGNALS and !DISABLE_PTHREAD. Progress output and error
messages are streamlined to minimize the flash footprint.

Signed-off-by: Swatantra Yadav <[email protected]>
Swatantra-66 added a commit to Swatantra-66/nuttx-apps that referenced this pull request Nov 1, 2026
Add automated unit test for pthread_sigqueue() in ostest to verify
signal and payload delivery to a target pthread. Tests error handling
for invalid signal numbers and non-existent thread IDs, as well as
successful signal dispatch and reception with SA_SIGINFO and SI_QUEUE.

Now that pthread_sigqueue() is implemented as a system call
(apache/nuttx#21070), the test runs across flat, protected, and
kernel builds.

Configurable via CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE, enabled by
default for non-small builds (!DEFAULT_SMALL) and gated by
ENABLE_ALL_SIGNALS and !DISABLE_PTHREAD. Progress output and error
messages are streamlined to minimize the flash footprint.

Signed-off-by: Swatantra Yadav <[email protected]>
xiaoxiang781216 pushed a commit to apache/nuttx-apps that referenced this pull request Nov 3, 2026
Add automated unit test for pthread_sigqueue() in ostest to verify
signal and payload delivery to a target pthread. Tests error handling
for invalid signal numbers and non-existent thread IDs, as well as
successful signal dispatch and reception with SA_SIGINFO and SI_QUEUE.

Now that pthread_sigqueue() is implemented as a system call
(apache/nuttx#21070), the test runs across flat, protected, and
kernel builds.

Configurable via CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE, enabled by
default for non-small builds (!DEFAULT_SMALL) and gated by
ENABLE_ALL_SIGNALS and !DISABLE_PTHREAD. Progress output and error
messages are streamlined to minimize the flash footprint.

Signed-off-by: Swatantra Yadav <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants