Print signal name strace killed with
As of now, there's no visible indication that strace itself has been signalled: it exits with exit code 0 and without any messages. Let's add a message, at least. * gcc_compat.h (CMPXCHG): New macro * strace.c (interrupt): set interrupted signal only once. (print_signalled): Add support for calling with tcp == NULL. (terminate): Call print_signalled is qflag is not set and strace has been interrupted.
This commit is contained in:
@ -87,6 +87,14 @@
|
||||
# define ALIGNOF(t_) (sizeof(struct { char x_; t_ y_; }) - sizeof(t_))
|
||||
#endif
|
||||
|
||||
#if GNUC_PREREQ(4, 1)
|
||||
# define CMPXCHG(val_, old_, new_) \
|
||||
__sync_bool_compare_and_swap((val_), (old_), (new_))
|
||||
#else
|
||||
# define CMPXCHG(val_, old_, new_) \
|
||||
((val_) == (old_) ? (val_) = (new_), true : false)
|
||||
#endif
|
||||
|
||||
#if GNUC_PREREQ(4, 3)
|
||||
# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
|
||||
#else
|
||||
|
28
strace.c
28
strace.c
@ -2020,7 +2020,8 @@ cleanup(void)
|
||||
static void
|
||||
interrupt(int sig)
|
||||
{
|
||||
interrupted = sig;
|
||||
/* Do not overwrite signal */
|
||||
CMPXCHG(&interrupted, 0, sig);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2154,21 +2155,30 @@ maybe_switch_tcbs(struct tcb *tcp, const int pid)
|
||||
static void
|
||||
print_signalled(struct tcb *tcp, const int pid, int status)
|
||||
{
|
||||
const char *prefix = "+++ ";
|
||||
const char *suffix = " +++\n";
|
||||
void (*printer)(const char *fmt, ...) = tprintf;
|
||||
|
||||
if (pid == strace_child) {
|
||||
exit_code = 0x100 | WTERMSIG(status);
|
||||
strace_child = 0;
|
||||
} else if (pid == strace_tracer_pid) {
|
||||
prefix = "";
|
||||
suffix = "";
|
||||
printer = error_msg;
|
||||
}
|
||||
|
||||
if (cflag != CFLAG_ONLY_STATS
|
||||
&& is_number_in_set(WTERMSIG(status), signal_set)) {
|
||||
printleader(tcp);
|
||||
if (tcp)
|
||||
printleader(tcp);
|
||||
#ifdef WCOREDUMP
|
||||
tprintf("+++ killed by %s %s+++\n",
|
||||
signame(WTERMSIG(status)),
|
||||
WCOREDUMP(status) ? "(core dumped) " : "");
|
||||
printer("%skilled by %s%s%s",
|
||||
prefix, signame(WTERMSIG(status)),
|
||||
WCOREDUMP(status) ? " (core dumped)" : "", suffix);
|
||||
#else
|
||||
tprintf("+++ killed by %s +++\n",
|
||||
signame(WTERMSIG(status)));
|
||||
printer("%skilled by %s%s",
|
||||
prefix, signame(WTERMSIG(status)), suffix);
|
||||
#endif
|
||||
line_ended();
|
||||
}
|
||||
@ -2809,6 +2819,10 @@ terminate(void)
|
||||
Exit with 128 + signo then. */
|
||||
exit_code += 128;
|
||||
}
|
||||
|
||||
if (!qflag && interrupted)
|
||||
print_signalled(NULL, strace_tracer_pid, interrupted);
|
||||
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user