This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

raise(SIGKILL)


I'm trying to streamline the behavior of a debugger catching (or not) a
program that is executing raise(SIGKILL).

$ cat raise.c
#include <signal.h>

int
main(int argc, char **argv)
{
	raise(SIGKILL);

	return 0;
}

I wrote a ptrace(2) example (extracted from the ATF suite from NetBSD
with compat code included):

http://netbsd.org/~kamil/kernel/traceme.c


FreeBSD works for this code reporting a stopped process.

Linux considers raise(SIGKILL) causing signaled as expected.

static int sig_ignored(struct task_struct *t, int sig, bool force)
{
	/*
	 * Blocked signals are never ignored, since the
	 * signal handler may change by the time it is
	 * unblocked.
	 */
	if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
		return 0;

	/*
	 * Tracers may want to know about even ignored signal unless it
	 * is SIGKILL which can't be reported anyway but can be ignored
	 * by SIGNAL_UNKILLABLE task.
	 */
	if (t->ptrace && sig != SIGKILL)
		return 0;

	return sig_task_ignored(t, sig, force);
}

https://elixir.bootlin.com/linux/latest/source/kernel/signal.c#L99


NetBSD is right now in the Linux camp.. I'm trying to assert its
behavior with regression tests but I'm unsure who is correct*.

* I know that it's largely OS specific and non-standard extension.

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]