summaryrefslogtreecommitdiff
path: root/die.c
blob: 4e525f9e15539434be76341c237ef06d7f0fe8f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Subject to the GPL, version 2.
 */

#include "xmalloc.h"

struct panic_handler {
	void *arg;
	pid_t pid;
	bool is_enabled;
	void (*on_panic)(void *arg);
	struct panic_handler *next;
};

static struct panic_handler *panic_handlers;

void panic_handler_add(void (*on_panic)(void *arg), void *arg)
{
	struct panic_handler *handler = xmallocz(sizeof(*handler));

	handler->arg		= arg;
	handler->pid		= getpid();
	handler->is_enabled	= true;
	handler->on_panic	= on_panic;
	handler->next		= panic_handlers;
	panic_handlers		= handler;
};

void call_panic_handlers(void)
{
	struct panic_handler *it;
	pid_t pid = getpid();

	for (it = panic_handlers; it; it = it->next) {
		if (it->pid == pid && it->is_enabled) {
			it->is_enabled = false;
			it->on_panic(it->arg);
		}
	}
}
2017-02-10sched: move tcf_proto_destroy and tcf_destroy_chain helpers into cls_apiJiri Pirko2-2/+2 2017-02-10sched: rename tcf_destroy to tcf_destroy_protoJiri Pirko1-1/+1 2017-02-10ipv4: fib: Add events for FIB replace and appendIdo Schimmel1-1/+2 2017-02-09sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Requ...Xin Long1-0/+2 2017-02-09sctp: add support for generating stream reconf add incoming/outgoing streams ...Xin Long1-0/+3 2017-02-09sctp: implement sender-side procedures for SSN/TSN Reset Request ParameterXin Long1-0/+1 2017-02-09sctp: add support for generating stream reconf ssn/tsn reset request chunkXin Long1-0/+2 2017-02-08ipv4: fib: Notify about nexthop status changesIdo Schimmel1-0/+7 2017-02-08gro_cells: move to net/core/gro_cells.cEric Dumazet1-82/+4 2017-02-07Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller