mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 10:46:28 +08:00
Modify SIGSTP to SIGTSTP
Follow the POSIX description. SIGTSTP should be sent when the Ctrl-Z characters is encountered, not SIGSTP. Testing: Built with hifive1-revb:nsh (CONFIG_SERIAL_TERMIOS=y, CONFIG_SIG_DEFAULT=y and CONFIG_TTY_SIGTSTP=y)
This commit is contained in:
committed by
Xiang Xiao
parent
96d1f018c4
commit
c13f869432
@@ -27,7 +27,7 @@ SIGUSR2 Abnormal Termination CONFIG_SIG_SIGUSR2_ACTION
|
||||
SIGALRM Abnormal Termination CONFIG_SIG_SIGALRM_ACTION
|
||||
SIGPOLL Abnormal Termination CONFIG_SIG_SIGPOLL_ACTION
|
||||
SIGSTOP Suspend task CONFIG_SIG_SIGSTOP_ACTION
|
||||
SIGSTP Suspend task CONFIG_SIG_SIGSTOP_ACTION
|
||||
SIGTSTP Suspend task CONFIG_SIG_SIGSTOP_ACTION
|
||||
SIGCONT Resume task CONFIG_SIG_SIGSTOP_ACTION
|
||||
SIGINT Abnormal Termination CONFIG_SIG_SIGKILL_ACTION
|
||||
SIGKILL Abnormal Termination CONFIG_SIG_SIGKILL_ACTION
|
||||
|
||||
@@ -718,7 +718,7 @@ o Signals (sched/signal, arch/)
|
||||
SIGALRM Abnormal Termination CONFIG_SIG_SIGALRM_ACTION
|
||||
SIGPOLL Abnormal Termination CONFIG_SIG_SIGPOLL_ACTION
|
||||
SIGSTOP Suspend task CONFIG_SIG_SIGSTOP_ACTION
|
||||
SIGSTP Suspend task CONFIG_SIG_SIGSTOP_ACTION
|
||||
SIGTSTP Suspend task CONFIG_SIG_SIGSTOP_ACTION
|
||||
SIGCONT Resume task CONFIG_SIG_SIGSTOP_ACTION
|
||||
SIGINT Abnormal Termination CONFIG_SIG_SIGKILL_ACTION
|
||||
SIGKILL Abnormal Termination CONFIG_SIG_SIGKILL_ACTION
|
||||
|
||||
@@ -100,7 +100,7 @@ CONFIG_SYSLOG_TIMESTAMP=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TTY_SIGINT=y
|
||||
CONFIG_TTY_SIGSTP=y
|
||||
CONFIG_TTY_SIGTSTP=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
CONFIG_UBOOT_UIMAGE=y
|
||||
CONFIG_UIMAGE_ENTRY_POINT=0x20008040
|
||||
|
||||
@@ -133,7 +133,7 @@ CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_SYSTEM_VI=y
|
||||
CONFIG_TTY_SIGINT=y
|
||||
CONFIG_TTY_SIGSTP=y
|
||||
CONFIG_TTY_SIGTSTP=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
CONFIG_UBOOT_UIMAGE=y
|
||||
CONFIG_UIMAGE_ENTRY_POINT=0x20008040
|
||||
|
||||
@@ -126,7 +126,7 @@ CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_SYSTEM_VI=y
|
||||
CONFIG_TTY_SIGINT=y
|
||||
CONFIG_TTY_SIGSTP=y
|
||||
CONFIG_TTY_SIGTSTP=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USBDEV_DMA=y
|
||||
|
||||
@@ -103,7 +103,7 @@ CONFIG_SYSLOG_TIMESTAMP=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TTY_SIGINT=y
|
||||
CONFIG_TTY_SIGSTP=y
|
||||
CONFIG_TTY_SIGTSTP=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
CONFIG_UBOOT_UIMAGE=y
|
||||
CONFIG_UIMAGE_ENTRY_POINT=0x20008040
|
||||
|
||||
@@ -130,7 +130,7 @@ CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_SYSTEM_VI=y
|
||||
CONFIG_TTY_SIGINT=y
|
||||
CONFIG_TTY_SIGSTP=y
|
||||
CONFIG_TTY_SIGTSTP=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USBDEV_DMA=y
|
||||
|
||||
@@ -116,7 +116,7 @@ CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_SYSTEM_VI=y
|
||||
CONFIG_TTY_SIGINT=y
|
||||
CONFIG_TTY_SIGSTP=y
|
||||
CONFIG_TTY_SIGTSTP=y
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USBDEV_DMA=y
|
||||
CONFIG_USBDEV_DUALSPEED=y
|
||||
|
||||
@@ -125,6 +125,6 @@ CONFIG_TELNET_CHARACTER_MODE=y
|
||||
CONFIG_TELNET_TXBUFFER_SIZE=64
|
||||
CONFIG_TTY_SIGINT=y
|
||||
CONFIG_TTY_SIGINT_CHAR=0x3
|
||||
CONFIG_TTY_SIGSTP=y
|
||||
CONFIG_TTY_SIGTSTP=y
|
||||
CONFIG_USERMAIN_STACKSIZE=4096
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
#endif
|
||||
|
||||
#undef HAVE_SIGNALS
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
|
||||
# define HAVE_SIGNALS
|
||||
#endif
|
||||
|
||||
@@ -289,18 +289,18 @@ static void telnet_check_ctrlchar(FAR struct telnet_dev_s *priv,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TTY_SIGSTP
|
||||
/* Is this the special character that will generate the SIGSTP
|
||||
#ifdef CONFIG_TTY_SIGTSTP
|
||||
/* Is this the special character that will generate the SIGTSTP
|
||||
* signal?
|
||||
*/
|
||||
|
||||
if (*buffer == CONFIG_TTY_SIGSTP_CHAR)
|
||||
if (*buffer == CONFIG_TTY_SIGTSTP_CHAR)
|
||||
{
|
||||
/* Note that the kill is needed and do not put the character
|
||||
* into the Rx buffer. It should not be read as normal data.
|
||||
*/
|
||||
|
||||
signo = SIGSTP;
|
||||
signo = SIGTSTP;
|
||||
#ifndef CONFIG_TTY_SIGINT
|
||||
break;
|
||||
#endif
|
||||
|
||||
+12
-12
@@ -192,14 +192,14 @@ config TTY_SIGINT
|
||||
INTR SIGINT Ctrl-C ETX(0x03) Interrupt
|
||||
KILL SIGKILL Ctrl-U NAK(0x15) Kill
|
||||
QUIT SIGQUIT Ctrl-\ FS (0x1c) Quit
|
||||
SUSP SIGSTP Ctrl-Z SUB(0x1a) Suspend
|
||||
DSUSP SIGSTP Ctrl-Y EM (0x19) Delayed suspend
|
||||
SUSP SIGTSTP Ctrl-Z SUB(0x1a) Suspend
|
||||
DSUSP SIGTSTP Ctrl-Y EM (0x19) Delayed suspend
|
||||
|
||||
Additional requirements:
|
||||
- SIGKILL cannot be caught or ignored. Compared to SIGTERM which
|
||||
is like SIGKILL but can be caught or ignored.
|
||||
- SIGQUIT is like SIGINT but causes generation of a core dump
|
||||
- SIGSTOP cannot be caught or ignored. SIGSTP is like SIGSTOP but
|
||||
- SIGSTOP cannot be caught or ignored. SIGTSTP is like SIGSTOP but
|
||||
can be caught or ignored.
|
||||
- The delayed suspend (DSUSD) is like suspend (SUPD), except that
|
||||
the suspension is delayed until the next read operation
|
||||
@@ -219,8 +219,8 @@ config TTY_SIGINT_CHAR
|
||||
REVISIT: Traditionally Ctrl-C would generate SIGINT. Ctrl-D is the
|
||||
End-of-File character that should close the stream.
|
||||
|
||||
config TTY_SIGSTP
|
||||
bool "Support SIGSTP"
|
||||
config TTY_SIGTSTP
|
||||
bool "Support SIGTSTP"
|
||||
default n
|
||||
select CONFIG_SIG_SIGSTOP_ACTION
|
||||
depends on SERIAL_TERMIOS
|
||||
@@ -237,24 +237,24 @@ config TTY_SIGSTP
|
||||
INTR SIGINT Ctrl-C ETX(0x03) Interrupt
|
||||
KILL SIGKILL Ctrl-U NAK(0x15) Kill
|
||||
QUIT SIGQUIT Ctrl-\ FS (0x1c) Quit
|
||||
SUSP SIGSTP Ctrl-Z SUB(0x1a) Suspend
|
||||
DSUSP SIGSTP Ctrl-Y EM (0x19) Delayed suspend
|
||||
SUSP SIGTSTP Ctrl-Z SUB(0x1a) Suspend
|
||||
DSUSP SIGTSTP Ctrl-Y EM (0x19) Delayed suspend
|
||||
|
||||
Additional requirements:
|
||||
- SIGKILL cannot be caught or ignored. Compared to SIGTERM which
|
||||
is like SIGKILL but can be caught or ignored.
|
||||
- SIGQUIT is like SIGINT but causes generation of a core dump
|
||||
- SIGSTOP cannot be caught or ignored. SIGSTP is like SIGSTOP but
|
||||
- SIGSTOP cannot be caught or ignored. SIGTSTP is like SIGSTOP but
|
||||
can be caught or ignored.
|
||||
- The delayed suspend (DSUSD) is like suspend (SUPD), except that
|
||||
the suspension is delayed until the next read operation
|
||||
|
||||
config TTY_SIGSTP_CHAR
|
||||
hex "Serial parse SIGSTP characters"
|
||||
config TTY_SIGTSTP_CHAR
|
||||
hex "Serial parse SIGTSTP characters"
|
||||
default 0x1a
|
||||
depends on TTY_SIGSTP
|
||||
depends on TTY_SIGTSTP
|
||||
---help---
|
||||
Use ASCII 0x1a (Ctrl-z) input to determine whether to send a SIGSTP
|
||||
Use ASCII 0x1a (Ctrl-z) input to determine whether to send a SIGTSTP
|
||||
event. Other characters may also be selected.
|
||||
|
||||
#
|
||||
|
||||
@@ -1372,7 +1372,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
|
||||
/* Make the controlling terminal of the calling process */
|
||||
|
||||
case TIOCSCTTY:
|
||||
@@ -1590,7 +1590,7 @@ errout:
|
||||
int uart_register(FAR const char *path, FAR uart_dev_t *dev)
|
||||
{
|
||||
#ifdef CONFIG_SERIAL_TERMIOS
|
||||
# if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||
# if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
|
||||
/* Initialize of the task that will receive SIGINT signals. */
|
||||
|
||||
dev->pid = (pid_t)-1;
|
||||
|
||||
+10
-10
@@ -55,7 +55,7 @@
|
||||
* Name: uart_check_signo
|
||||
*
|
||||
* Description:
|
||||
* Check if the SIGINT or SIGSTP character is in the contiguous Rx DMA
|
||||
* Check if the SIGINT or SIGTSTP character is in the contiguous Rx DMA
|
||||
* buffer region. The first signal associated with the first such
|
||||
* character is returned.
|
||||
*
|
||||
@@ -64,12 +64,12 @@
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 if a signal-related character does not appear in the. Otherwise,
|
||||
* SIGKILL or SIGSTP may be returned to indicate the appropriate signal
|
||||
* SIGKILL or SIGTSTP may be returned to indicate the appropriate signal
|
||||
* action.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
|
||||
static int uart_check_signo(const char *buf, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
@@ -83,10 +83,10 @@ static int uart_check_signo(const char *buf, size_t size)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TTY_SIGSTP
|
||||
if (buf[i] == CONFIG_TTY_SIGSTP_CHAR)
|
||||
#ifdef CONFIG_TTY_SIGTSTP
|
||||
if (buf[i] == CONFIG_TTY_SIGTSTP_CHAR)
|
||||
{
|
||||
return SIGSTP;
|
||||
return SIGTSTP;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -102,13 +102,13 @@ static int uart_check_signo(const char *buf, size_t size)
|
||||
* Check if the SIGINT character is anywhere in the newly received DMA
|
||||
* buffer.
|
||||
*
|
||||
* REVISIT: We must also remove the SIGINT/SIGSTP character from the Rx
|
||||
* REVISIT: We must also remove the SIGINT/SIGTSTP character from the Rx
|
||||
* buffer. It should not be read as normal data by the caller.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SERIAL_RXDMA) && \
|
||||
(defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP))
|
||||
(defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP))
|
||||
static int uart_recvchars_signo(FAR uart_dev_t *dev)
|
||||
{
|
||||
FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
|
||||
@@ -370,7 +370,7 @@ void uart_recvchars_done(FAR uart_dev_t *dev)
|
||||
FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
|
||||
FAR struct uart_buffer_s *rxbuf = &dev->recv;
|
||||
size_t nbytes = xfer->nbytes;
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
|
||||
int signo = 0;
|
||||
|
||||
/* Check if the SIGINT character is anywhere in the newly received DMA
|
||||
@@ -398,7 +398,7 @@ void uart_recvchars_done(FAR uart_dev_t *dev)
|
||||
uart_datareceived(dev);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
|
||||
/* Send the signal if necessary */
|
||||
|
||||
if (signo != 0)
|
||||
|
||||
@@ -139,7 +139,7 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
||||
#endif
|
||||
unsigned int status;
|
||||
int nexthead = rxbuf->head + 1;
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
|
||||
int signo = 0;
|
||||
#endif
|
||||
uint16_t nbytes = 0;
|
||||
@@ -233,13 +233,13 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef CONFIG_TTY_SIGSTP
|
||||
/* Is this the special character that will generate the SIGSTP
|
||||
#ifdef CONFIG_TTY_SIGTSTP
|
||||
/* Is this the special character that will generate the SIGTSTP
|
||||
* signal?
|
||||
*/
|
||||
|
||||
if (dev->pid >= 0 && (dev->tc_lflag & ISIG) &&
|
||||
ch == CONFIG_TTY_SIGSTP_CHAR)
|
||||
ch == CONFIG_TTY_SIGTSTP_CHAR)
|
||||
{
|
||||
#ifdef CONFIG_TTY_SIGINT
|
||||
/* Give precedence to SIGINT */
|
||||
@@ -251,7 +251,7 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
||||
* into the Rx buffer. It should not be read as normal data.
|
||||
*/
|
||||
|
||||
signo = SIGSTP;
|
||||
signo = SIGTSTP;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -292,7 +292,7 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
||||
uart_datareceived(dev);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
|
||||
/* Send the signal if necessary */
|
||||
|
||||
if (signo != 0)
|
||||
|
||||
@@ -300,7 +300,7 @@ struct uart_dev_s
|
||||
tcflag_t tc_iflag; /* Input modes */
|
||||
tcflag_t tc_oflag; /* Output modes */
|
||||
tcflag_t tc_lflag; /* Local modes */
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP)
|
||||
pid_t pid; /* Thread PID to receive signals (-1 if none) */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@
|
||||
|
||||
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
||||
# define SIGSTOP CONFIG_SIG_STOP
|
||||
# define SIGSTP CONFIG_SIG_STP
|
||||
# define SIGTSTP CONFIG_SIG_TSTP
|
||||
# define SIGCONT CONFIG_SIG_CONT
|
||||
#endif
|
||||
|
||||
|
||||
@@ -143,9 +143,9 @@ FAR char *strsignal(int signum)
|
||||
return (FAR char *)"SIGSTOP";
|
||||
#endif
|
||||
|
||||
#ifdef SIGSTP
|
||||
case SIGSTP:
|
||||
return (FAR char *)"SIGSTP";
|
||||
#ifdef SIGTSTP
|
||||
case SIGTSTP:
|
||||
return (FAR char *)"SIGTSTP";
|
||||
#endif
|
||||
|
||||
#ifdef SIGCONT
|
||||
|
||||
+4
-4
@@ -1382,10 +1382,10 @@ config SIG_SIGPOLL_ACTION
|
||||
sigaction() to ignore SIGPOLL.
|
||||
|
||||
config SIG_SIGSTOP_ACTION
|
||||
bool "SIGSTOP SIGSTP, and SIGCONT"
|
||||
bool "SIGSTOP SIGTSTP, and SIGCONT"
|
||||
default y
|
||||
---help---
|
||||
Enable the default action for SIGSTOP and SIGSTP (suspend the
|
||||
Enable the default action for SIGSTOP and SIGTSTP (suspend the
|
||||
task) and SIGCONT (resume the task).
|
||||
|
||||
config SIG_SIGKILL_ACTION
|
||||
@@ -1452,8 +1452,8 @@ config SIG_STOP
|
||||
---help---
|
||||
Suspend/pause a task. SIGSTOP may not be caught or ignored.
|
||||
|
||||
config SIG_STP
|
||||
int "SIGSTP"
|
||||
config SIG_TSTP
|
||||
int "SIGTSTP"
|
||||
default 7
|
||||
depends on SIG_SIGSTOP_ACTION
|
||||
---help---
|
||||
|
||||
@@ -86,7 +86,7 @@ static int group_suspend_children_handler(pid_t pid, FAR void *arg)
|
||||
*
|
||||
* Description:
|
||||
* Suspend all children of a task except for the specified task. This is
|
||||
* SIGSTP/SIGSTOP default signal action logic. When the main task is
|
||||
* SIGTSTP/SIGSTOP default signal action logic. When the main task is
|
||||
* suspended, all of its child pthreads must also be suspended.
|
||||
*
|
||||
* Input Parameters:
|
||||
|
||||
@@ -194,7 +194,7 @@ volatile dq_queue_t g_waitingforfill;
|
||||
|
||||
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
||||
/* This is the list of all tasks that have been stopped
|
||||
* via SIGSTOP or SIGSTP
|
||||
* via SIGSTOP or SIGTSTP
|
||||
*/
|
||||
|
||||
volatile dq_queue_t g_stoppedtasks;
|
||||
|
||||
@@ -134,7 +134,7 @@ static const struct nxsig_defaction_s g_defactions[] =
|
||||
#endif
|
||||
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
||||
{ SIGSTOP, SIG_FLAG_NOCATCH, nxsig_stop_task },
|
||||
{ SIGSTP, 0, nxsig_stop_task },
|
||||
{ SIGTSTP, 0, nxsig_stop_task },
|
||||
{ SIGCONT, SIG_FLAG_NOCATCH, nxsig_null_action },
|
||||
#endif
|
||||
#ifdef CONFIG_SIG_SIGKILL_ACTION
|
||||
|
||||
@@ -451,7 +451,7 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
||||
/* If the task was stopped by SIGSTOP or SIGSTP, then unblock the task
|
||||
/* If the task was stopped by SIGSTOP or SIGTSTP, then unblock the task
|
||||
* if SIGCONT is received.
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user