Skip to content

[BUG] Serial TTY Signal Regression #16935

Description

@pryre

Description / Steps to reproduce the issue

Summary

I believe there's been a behavior regression caused by #14104, may also be related to #16334.

Impact

Behavior:

  • Before: sending a SIGINT (via CONFIG_TTY_SIGINT) gets received by arbitrary programs run through NSH
  • After: sending a SIGINT (via CONFIG_TTY_SIGINT) gets processed, but is ignored due to a group mismatch on sig_dispatch.c:736.

The actual issue seems to be with the check of group == this_task()->group, where a program in sleep passes off to the scheduler (? sorry, I'm not familiar with the specifics), meaning that this_task()->group gets the group from g_idletcb which does not match the program sleeping in the foreground.

Testing

Reverting changes from nxsig_tgkill() to nxsig_kill() allow signals to be received by a program in usleep().

Using the nucleo-l432kc:nsh configuration, with the following config changes:

CONFIG_TTY_SIGINT=y
CONFIG_TTY_SIGINT_CHAR=0x03

CONFIG_SIG_DEFAULT=y
CONFIG_SIG_SIGKILL_ACTION=y
CONFIG_SIG_SIGSTOP_ACTION=y
CONFIG_GROUP_KILL_CHILDREN_TIMEOUT_MS=-1

CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_HELLO_PROGNAME="hello"
CONFIG_EXAMPLES_HELLO_PRIORITY=100
CONFIG_EXAMPLES_HELLO_STACKSIZE=2048

Example implementation using hello example app:

/****************************************************************************
 * apps/examples/hello/hello_main.c
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.  The
 * ASF licenses this file to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *
 ****************************************************************************/

/****************************************************************************
 * Included Files
 ****************************************************************************/

#include <nuttx/config.h>
#include <stdio.h>
#include <signal.h>

/****************************************************************************
 * Public Functions
 ****************************************************************************/

volatile bool _ok;
void _handler(int sig) {
  _ok = false;
}

/****************************************************************************
 * hello_main
 ****************************************************************************/

int main(int argc, FAR char *argv[])
{
  printf("Hello, World...\n");
  
  _ok = true;
  signal(SIGINT, _handler);

  while(_ok) {
    usleep(10*1000*1000);
  }

  printf("Bye!\n");

  return 0;
}

Output pressing CTRL-C before changes during the usleep():

Hello, World...
Bye!

Output pressing CTRL-C before changes during the usleep():

Hello, World...

Where the program never exits.

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

OpenSUSE Linux 6.15.8-1.0.2.sr20250701-default

NuttX Version

12.10.0

Issue Architecture

[Arch: arm]

Issue Area

[Area: Posix]

Host information

No response

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arch: armIssues related to ARM (32-bit) architectureArea: PosixPosix issuesOS: LinuxIssues related to Linux (building system, etc)Type: BugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions