1#!/usr/sbin/dtrace -qs 2/* 3 * kill.d - watch process signals as they are sent (eg, kill -9). 4 * Written in DTrace (Solaris 10 3/05). 5 * 6 * 28-Jun-2005, ver 1.10 7 * 8 * USAGE: kill.d 9 * 10 * FIELDS: 11 * FROM source PID 12 * COMMAND source command name 13 * TO destination PID 14 * SIG destination signal ("9" for a kill -9) 15 * RESULT result of signal (-1 is for failure) 16 * 17 * SEE ALSO: Chapter 25, Solaris Dynamic Tracing Guide, docs.sun.com, 18 * for a solution using proc:::signal-send. 19 * 20 * COPYRIGHT: Copyright (c) 2005 Brendan Gregg. 21 * 22 * CDDL HEADER START 23 * 24 * The contents of this file are subject to the terms of the 25 * Common Development and Distribution License, Version 1.0 only 26 * (the "License"). You may not use this file except in compliance 27 * with the License. 28 * 29 * You can obtain a copy of the license at Docs/cddl1.txt 30 * or http://www.opensolaris.org/os/licensing. 31 * See the License for the specific language governing permissions 32 * and limitations under the License. 33 * 34 * CDDL HEADER END 35 * 36 * 09-May-2004 Brendan Gregg Created this. 37 */ 38 39dtrace:::BEGIN 40{ 41 /* Print header */ 42 printf("%5s %12s %5s %-6s %s\n", 43 "FROM", "COMMAND", "SIG", "TO", "RESULT"); 44} 45 46syscall::kill:entry 47{ 48 /* Record target PID and signal */ 49 self->target = arg0; 50 self->signal = arg1; 51} 52 53syscall::kill:return 54{ 55 /* Print source, target, and result */ 56 printf("%5d %12s %5d %-6d %d\n", 57 pid, execname, self->signal, self->target, (int)arg0); 58 59 /* Cleanup memory */ 60 self->target = 0; 61 self->signal = 0; 62} 63