Just wondering about the difference between SIGSTOP
and SIGTSTP
signals.
Both signals are designed to suspend a process which will be eventually resumed with SIGCONT
. The main differences between them are:
SIGSTOP
is a signal sent programmatically (eg:kill -STOP pid
) whileSIGTSTP
(for signal - terminal stop) may also be sent through thetty
driver by a user typing on a keyboard, usually Control-Z.SIGSTOP
cannot be ignored.SIGTSTP
might be.
Control-Z
doesn't trigger SIGTSTP
or do you think it should not? –
Uruguay terminal stop
means TSTP. –
Uruguay SIGSTOP
can be send only through command kill -STOP pid
and SIGTSTP
can be send in 2 ways, through command and by ctrl
+ z
- Am I correct? –
Knowhow SIGSTOP
can be sent by most programming languages, not only the shell. For example in python, that would be os.kill(pid, signal.SIGSTOP)
–
Uruguay According with the /usr/include/x86_64-linux-gnu/bits/signum.h
file exists the following:
#define SIGSTOP 19 /* Stop, unblockable (POSIX). */
#define SIGTSTP 20 /* Keyboard stop (POSIX). */
/usr/include/sys/iso/signal_iso.h
–
Redfin /usr/include/sys/signal.h
–
Emotionalism SIGSTOP can't be ignored by the targetted process.
A good example of that is the video player mpv
, it can ignore SIGTSTP
but not SIGSTOP
.
You can test with a video running :
kill -SIGTSTP $(pidof mpv)
and
kill -SIGSTOP $(pidof mpv)
Of course kill -SIGCONT $(pidof mpv)
to resume playing.
on macOS, execute command man signal
to read signal documentation.
# | Name | Default Action | Description |
---|---|---|---|
17 | SIGSTOP | stop process | stop (cannot be caught or ignored) |
18 | SIGTSTP | stop process | stop signal generated from keyboard |
There are two differences between them:
SIGTSTP
can be caught or ignored,SIGSTOP
cannot.SIGTSTP
can be generated from keyboard (CTRL+Z),SIGSTOP
cannot.
on 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 - 2024 — McMap. All rights reserved.