diff options
author | Jesper Derehag <jderehag@hotmail.com> | 2013-03-19 20:50:05 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-03-20 13:23:21 -0400 |
commit | 2b5faa4c553f90ee2dde1d976b220b1ca9741ef0 (patch) | |
tree | 91d6d907a0bc8ef659fee414d5415a84aee7b58b /drivers/connector/cn_proc.c | |
parent | 800c644bcd0f2b29020c0dd6b661596c14c0f34f (diff) | |
download | linux-2b5faa4c553f90ee2dde1d976b220b1ca9741ef0.tar.gz linux-2b5faa4c553f90ee2dde1d976b220b1ca9741ef0.tar.bz2 linux-2b5faa4c553f90ee2dde1d976b220b1ca9741ef0.zip |
connector: Added coredumping event to the process connector
Process connector can now also detect coredumping events.
Main aim of patch is get notified at start of coredumping, instead of
having to wait for it to finish and then being notified through EXIT
event.
Could be used for instance by process-managers that want to get
notified as soon as possible about process failures, and not
necessarily beeing notified after coredump, which could be in the
order of minutes depending on size of coredump, piping and so on.
Signed-off-by: Jesper Derehag <jderehag@hotmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/connector/cn_proc.c')
-rw-r--r-- | drivers/connector/cn_proc.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c index 1110478dd0fd..08ae128cce9b 100644 --- a/drivers/connector/cn_proc.c +++ b/drivers/connector/cn_proc.c @@ -232,6 +232,31 @@ void proc_comm_connector(struct task_struct *task) cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); } +void proc_coredump_connector(struct task_struct *task) +{ + struct cn_msg *msg; + struct proc_event *ev; + __u8 buffer[CN_PROC_MSG_SIZE]; + struct timespec ts; + + if (atomic_read(&proc_event_num_listeners) < 1) + return; + + msg = (struct cn_msg *)buffer; + ev = (struct proc_event *)msg->data; + get_seq(&msg->seq, &ev->cpu); + ktime_get_ts(&ts); /* get high res monotonic timestamp */ + put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns); + ev->what = PROC_EVENT_COREDUMP; + ev->event_data.coredump.process_pid = task->pid; + ev->event_data.coredump.process_tgid = task->tgid; + + memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); + msg->ack = 0; /* not used */ + msg->len = sizeof(*ev); + cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL); +} + void proc_exit_connector(struct task_struct *task) { struct cn_msg *msg; |