This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 2bfff207fd8 drivers/serial: Fix SIGINT not delivered to foreground 
process on Ctrl-C.
2bfff207fd8 is described below

commit 2bfff207fd8c24b5f2edbf684766217d1b0684da
Author: yinshengkai <[email protected]>
AuthorDate: Tue Dec 30 20:02:41 2025 +0800

    drivers/serial: Fix SIGINT not delivered to foreground process on Ctrl-C.
    
    When pressing Ctrl-C, the foreground process did not receive SIGINT
    and failed to terminate.
    
    The serial driver called nxsig_tgkill(-1, dev->pid, signo) from
    interrupt context. With pid=-1, nxsig_dispatch() was called with
    thread=true, which requires stcb->group == this_task()->group.
    However, in interrupt context, this_task() returns the IDLE task,
    whose group differs from the target process group. This caused
    the signal dispatch to fail with -ESRCH.
    
    Solution:
    Replace nxsig_tgkill(-1, pid, signo) with nxsig_kill(pid, signo).
    nxsig_kill() uses thread=false, which routes through group_signal()
    without the same-group check, allowing signals to be delivered
    correctly from interrupt context.
    
    Impact:
    - Fixes Ctrl-C signal delivery in serial console
    - No API changes
    - Affects serial driver interrupt handling only
    
    Testing: Verified on QEMU ARM64 simulator with serial console
    
    Signed-off-by: yinshengkai <[email protected]>
---
 drivers/serial/serial_dma.c | 2 +-
 drivers/serial/serial_io.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_dma.c b/drivers/serial/serial_dma.c
index 1e5f0df55f0..d4b86600915 100644
--- a/drivers/serial/serial_dma.c
+++ b/drivers/serial/serial_dma.c
@@ -354,7 +354,7 @@ void uart_recvchars_done(FAR uart_dev_t *dev)
 
   if (signo != 0)
     {
-      nxsig_tgkill(-1, dev->pid, signo);
+      nxsig_kill(dev->pid, signo);
     }
 #endif
 }
diff --git a/drivers/serial/serial_io.c b/drivers/serial/serial_io.c
index 54f4542d8d5..c88875a1342 100644
--- a/drivers/serial/serial_io.c
+++ b/drivers/serial/serial_io.c
@@ -311,7 +311,7 @@ void uart_recvchars(FAR uart_dev_t *dev)
 
   if (signo != 0)
     {
-      nxsig_tgkill(-1, dev->pid, signo);
+      nxsig_kill(dev->pid, signo);
     }
 #endif
 }

Reply via email to