1N/A#!/usr/sbin/dtrace -qs
1N/A/*
1N/A * kill.d - watch process signals as they are sent (eg, kill -9).
1N/A * Written in DTrace (Solaris 10 3/05).
1N/A *
1N/A * $Id: kill.d 3 2007-08-01 10:50:08Z brendan $
1N/A *
1N/A * USAGE: kill.d
1N/A *
1N/A * FIELDS:
1N/A * FROM source PID
1N/A * COMMAND source command name
1N/A * TO destination PID
1N/A * SIG destination signal ("9" for a kill -9)
1N/A * RESULT result of signal (-1 is for failure)
1N/A *
2N/A * SEE ALSO: Chapter 25, Solaris Dynamic Tracing Guide, docs.oracle.com,
1N/A * for a solution using proc:::signal-send.
1N/A *
1N/A * COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
1N/A *
1N/A * CDDL HEADER START
1N/A *
1N/A * The contents of this file are subject to the terms of the
1N/A * Common Development and Distribution License, Version 1.0 only
1N/A * (the "License"). You may not use this file except in compliance
1N/A * with the License.
1N/A *
1N/A * You can obtain a copy of the license at Docs/cddl1.txt
1N/A * or http://www.opensolaris.org/os/licensing.
1N/A * See the License for the specific language governing permissions
1N/A * and limitations under the License.
1N/A *
1N/A * CDDL HEADER END
1N/A *
1N/A * 09-May-2004 Brendan Gregg Created this.
1N/A * 28-Jun-2005 " " Last update.
1N/A */
1N/A
1N/Adtrace:::BEGIN
1N/A{
1N/A /* Print header */
1N/A printf("%5s %12s %5s %-6s %s\n",
1N/A "FROM", "COMMAND", "SIG", "TO", "RESULT");
1N/A}
1N/A
1N/Asyscall::kill:entry
1N/A{
1N/A /* Record target PID and signal */
1N/A self->target = arg0;
1N/A self->signal = arg1;
1N/A}
1N/A
1N/Asyscall::kill:return
1N/A{
1N/A /* Print source, target, and result */
1N/A printf("%5d %12s %5d %-6d %d\n",
1N/A pid, execname, self->signal, self->target, (int)arg0);
1N/A
1N/A /* Cleanup memory */
1N/A self->target = 0;
1N/A self->signal = 0;
1N/A}