]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Proc/kill.d
MFC r368207,368607:
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Proc / kill.d
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  * $Id: kill.d 3 2007-08-01 10:50:08Z brendan $
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  * 28-Jun-2005     "      "     Last update.
38  */
39
40 dtrace:::BEGIN
41 {
42         /* Print header */
43         printf("%5s %12s %5s %-6s %s\n",
44             "FROM", "COMMAND", "SIG", "TO", "RESULT");
45 }
46
47 syscall::kill:entry
48 {
49         /* Record target PID and signal */
50         self->target = arg0;
51         self->signal = arg1;
52 }
53
54 syscall::kill:return
55 {
56         /* Print source, target, and result */
57         printf("%5d %12s %5d %-6d %d\n",
58             pid, execname, self->signal, self->target, (int)arg0);
59
60         /* Cleanup memory */
61         self->target = 0;
62         self->signal = 0;
63 }