Commit b086ff87 authored by Stefan Strogin's avatar Stefan Strogin Committed by David S. Miller

connector: add parent pid and tgid to coredump and exit events

The intention is to get notified of process failures as soon
as possible, before a possible core dumping (which could be very long)
(e.g. in some process-manager). Coredump and exit process events
are perfect for such use cases (see 2b5faa4c "connector: Added
coredumping event to the process connector").

The problem is that for now the process-manager cannot know the parent
of a dying process using connectors. This could be useful if the
process-manager should monitor for failures only children of certain
parents, so we could filter the coredump and exit events by parent
process and/or thread ID.

Add parent pid and tgid to coredump and exit process connectors event
data.
Signed-off-by: default avatarStefan Strogin <sstrogin@cisco.com>
Acked-by: default avatarEvgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e283de3a
...@@ -262,6 +262,8 @@ void proc_coredump_connector(struct task_struct *task) ...@@ -262,6 +262,8 @@ void proc_coredump_connector(struct task_struct *task)
ev->what = PROC_EVENT_COREDUMP; ev->what = PROC_EVENT_COREDUMP;
ev->event_data.coredump.process_pid = task->pid; ev->event_data.coredump.process_pid = task->pid;
ev->event_data.coredump.process_tgid = task->tgid; ev->event_data.coredump.process_tgid = task->tgid;
ev->event_data.coredump.parent_pid = task->real_parent->pid;
ev->event_data.coredump.parent_tgid = task->real_parent->tgid;
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */ msg->ack = 0; /* not used */
...@@ -288,6 +290,8 @@ void proc_exit_connector(struct task_struct *task) ...@@ -288,6 +290,8 @@ void proc_exit_connector(struct task_struct *task)
ev->event_data.exit.process_tgid = task->tgid; ev->event_data.exit.process_tgid = task->tgid;
ev->event_data.exit.exit_code = task->exit_code; ev->event_data.exit.exit_code = task->exit_code;
ev->event_data.exit.exit_signal = task->exit_signal; ev->event_data.exit.exit_signal = task->exit_signal;
ev->event_data.exit.parent_pid = task->real_parent->pid;
ev->event_data.exit.parent_tgid = task->real_parent->tgid;
memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
msg->ack = 0; /* not used */ msg->ack = 0; /* not used */
......
...@@ -116,12 +116,16 @@ struct proc_event { ...@@ -116,12 +116,16 @@ struct proc_event {
struct coredump_proc_event { struct coredump_proc_event {
__kernel_pid_t process_pid; __kernel_pid_t process_pid;
__kernel_pid_t process_tgid; __kernel_pid_t process_tgid;
__kernel_pid_t parent_pid;
__kernel_pid_t parent_tgid;
} coredump; } coredump;
struct exit_proc_event { struct exit_proc_event {
__kernel_pid_t process_pid; __kernel_pid_t process_pid;
__kernel_pid_t process_tgid; __kernel_pid_t process_tgid;
__u32 exit_code, exit_signal; __u32 exit_code, exit_signal;
__kernel_pid_t parent_pid;
__kernel_pid_t parent_tgid;
} exit; } exit;
} event_data; } event_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment