128

只是想知道 SIGSTOP 和 SIGTSTP 信号之间的区别。

4

4 回答 4

182

这两个信号都旨在暂停一个最终将恢复的进程SIGCONT。它们之间的主要区别是:

  • SIGSTOP是以编程方式发送的信号(例如:)kill -STOP pid,而SIGTSTP(对于信号-终端停止)也可以tty由用户在键盘上键入通过驱动程序发送,通常是Control- Z

  • SIGSTOP不容忽视。SIGTSTP可能。

于 2012-08-09T16:41:52.673 回答
47

/usr/include/x86_64-linux-gnu/bits/signum.h

#define SIGSTOP     19  /* Stop, unblockable (POSIX).  */
#define SIGTSTP     20  /* Keyboard stop (POSIX).  */
于 2013-04-22T02:10:12.717 回答
2

目标进程不能忽略 SIGSTOP。

一个很好的例子就是视频播放器mpv,它可以忽略SIGTSTP但不能SIGSTOP

您可以使用正在运行的视频进行测试:

kill -SIGTSTP $(pidof mpv)kill -SIGSTOP $(pidof mpv)

当然kill -SIGCONT $(pidof mpv)要恢复播放。

于 2018-09-30T05:56:46.383 回答
0

在 ubuntu 上, /usr/include/x86_64-linux-gnu/bits/signum-generic.h

#ifdef __USE_XOPEN
# define SIG_HOLD ((__sighandler_t) 2)  /* Add signal to hold mask.  */
#endif

/* We define here all the signal names listed in POSIX (1003.1-2008);
   as of 1003.1-2013, no additional signals have been added by POSIX.
   We also define here signal names that historically exist in every
   real-world POSIX variant (e.g. SIGWINCH).

   Signals in the 1-15 range are defined with their historical numbers.
   For other signals, we use the BSD numbers.
   There are two unallocated signal numbers in the 1-31 range: 7 and 29.
   Signal number 0 is reserved for use as kill(pid, 0), to test whether
   a process exists without sending it a signal.  */

/* ISO C99 signals.  */
#define SIGINT      2   /* Interactive attention signal.  */
#define SIGILL      4   /* Illegal instruction.  */
#define SIGABRT     6   /* Abnormal termination.  */
#define SIGFPE      8   /* Erroneous arithmetic operation.  */
#define SIGSEGV     11  /* Invalid access to storage.  */
#define SIGTERM     15  /* Termination request.  */

/* Historical signals specified by POSIX. */
#define SIGHUP      1   /* Hangup.  */
#define SIGQUIT     3   /* Quit.  */
#define SIGTRAP     5   /* Trace/breakpoint trap.  */
#define SIGKILL     9   /* Killed.  */
#define SIGBUS      10  /* Bus error.  */
#define SIGSYS      12  /* Bad system call.  */
#define SIGPIPE     13  /* Broken pipe.  */
#define SIGALRM     14  /* Alarm clock.  */

/* New(er) POSIX signals (1003.1-2008, 1003.1-2013).  */
#define SIGURG      16  /* Urgent data is available at a socket.  */
#define SIGSTOP     17  /* Stop, unblockable.  */
#define SIGTSTP     18  /* Keyboard stop.  */
#define SIGCONT     19  /* Continue.  */
#define SIGCHLD     20  /* Child terminated or stopped.  */
#define SIGTTIN     21  /* Background read from control terminal.  */
#define SIGTTOU     22  /* Background write to control terminal.  */
#define SIGPOLL     23  /* Pollable event occurred (System V).  */
#define SIGXCPU     24  /* CPU time limit exceeded.  */
#define SIGXFSZ     25  /* File size limit exceeded.  */
#define SIGVTALRM   26  /* Virtual timer expired.  */
#define SIGPROF     27  /* Profiling timer expired.  */
#define SIGUSR1     30  /* User-defined signal 1.  */
#define SIGUSR2     31  /* User-defined signal 2.  */

于 2022-01-08T06:48:09.033 回答