From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 5 05:00:12 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94035106566B; Sun, 5 Dec 2010 05:00:12 +0000 (UTC) (envelope-from jamesbrandongooch@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id E7EEB8FC08; Sun, 5 Dec 2010 05:00:11 +0000 (UTC) Received: by wwf26 with SMTP id 26so6682892wwf.31 for ; Sat, 04 Dec 2010 21:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=CiLB7RYC6fJY7usCL9Mo/G5qU3UvOdpeErV3qOgjDrs=; b=mseZX+5lViVcSoxz7a7M1a0hTwqe+dM4SQQMCKhG+ZaOV/BFjc2i/jNJt2axL9dJk5 acNxQxBsDuGT6bKvuhStKcq2DunfJkGnXOtdFiYSqx7+Cge+qfdkwfn4baJzDZ6LpgCP 5GlcnpYQSdHVeVJexMsph/NXaVKn3DpAO/row= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=JdP1rB7sTdjgLeY0OsP+/dh+i/XsKrDpvWju+j980mx1p+fU0RqoK/r0picyIz/9Cn UUoaLS50hBDTuBISwwgH/NJiVLiHGxHwODJf3WY5HlSGCQbijhgtap3RfueVdkxiQLC5 CXLuaEDMV8NlHVIRc6zXDDZyjPtyKhDO/YDfo= MIME-Version: 1.0 Received: by 10.216.93.9 with SMTP id k9mr3321925wef.89.1291525210342; Sat, 04 Dec 2010 21:00:10 -0800 (PST) Received: by 10.216.12.80 with HTTP; Sat, 4 Dec 2010 21:00:09 -0800 (PST) In-Reply-To: References: <4CFAA579.1010701@freebsd.org> Date: Sat, 4 Dec 2010 23:00:09 -0600 Message-ID: From: Brandon Gooch To: Andriy Gapon Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org, Artem Belevich Subject: Re: DTrace: Sending ^C while running script produces no output X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Dec 2010 05:00:12 -0000 On Sat, Dec 4, 2010 at 3:27 PM, Brandon Gooch wrote: > On Sat, Dec 4, 2010 at 2:32 PM, Andriy Gapon wrote: >> on 03/12/2010 07:20 Brandon Gooch said the following: >>> I've been tinkering with DTrace a bit, and I've notice something >>> peculiar on each system I've tried it on. >>> >>> Sending ^C from the keyboard in the terminal (console, XTerm, Konsole) >>> produces no output [1]. >> >> Can you ktrace the dtrace process? >> I wonder, could it be that SIGINT from ^C is somehow delivered twice?.. > > I'll give it a shot in just a bit. I think you are correct, see below. > >>> For example, while trying out a one-liner (from >>> http://www.brendangregg.com/DTrace/dtrace_oneliners.txt): >>> >>> brandon@d820:~$ sudo dtrace -n 'syscall:::entry { @num[execname] =3D co= unt(); }' >>> dtrace: description 'syscall:::entry ' matched 514 probes >>> ^C >> >> BTW, sudo might play a role here... =A0Just a thought. > > I could see that for sure. I can't believe I hadn't thought of that > right off the bat, but then again I tested while logged in as root > from the console -- I think :/ > > Human memory is unreliable y'know... You were absolutely on to it -- sudo appears to be the culprit here. I ktrace'd both an attempt using sudo and not using sudo (as root). Snippet of ktrace output when running the aforementioned dtrace command as root, which works as expected: 8804 initial thread PSIG SIGINT caught handler=3D0x80065d0d0 mask=3D0x0 = code=3D0x0 8804 initial thread CALL sigprocmask(SIG_SETMASK,0x7fffffffe06c,0) 8804 initial thread RET sigprocmask 0 8804 initial thread CALL sigreturn(0x7fffffffdc90) 8804 initial thread RET sigreturn JUSTRETURN 8804 initial thread CALL fstat(0x1,0x7fffffffe000) 8804 initial thread STRU struct stat {dev=3D67174144, ino=3D120, mode=3D= crw--w---- , nlink=3D1, uid=3D1001, gid=3D4, rdev=3D120, atime=3D1291504111, stime=3D1= 291504111, ctime=3D 1291504111, birthtime=3D-1, size=3D0, blksize=3D4096, blocks=3D0, flags=3D0= x0 } 8804 initial thread RET fstat 0 8804 initial thread CALL ioctl(0x1,TIOCGETA,0x7fffffffe050) 8804 initial thread RET ioctl 0 8804 initial thread CALL write(0x1,0x8029b6000,0x1) 8804 initial thread GIO fd 1 wrote 1 byte " Snippet of ktrace output when running the aforementioned dtrace command with sudo, which produces no output: 4527 initial thread PSIG SIGINT caught handler=3D0x80065d0d0 mask=3D0x0 = code=3D0x0 4527 initial thread CALL sigprocmask(SIG_SETMASK,0x7fffffffe22c,0) 4527 initial thread RET sigprocmask 0 4527 initial thread CALL sigreturn(0x7fffffffde50) 4527 initial thread RET sigreturn JUSTRETURN 4527 initial thread PSIG SIGINT caught handler=3D0x80065d0d0 mask=3D0x0 = code=3D0x0 4527 initial thread CALL sigprocmask(SIG_SETMASK,0x7fffffffe22c,0) 4527 initial thread RET sigprocmask 0 4527 initial thread CALL sigreturn(0x7fffffffde50) 4527 initial thread RET sigreturn JUSTRETURN 4527 initial thread PSIG SIGINT caught handler=3D0x80065d0d0 mask=3D0x0 = code=3D0x0 4527 initial thread CALL sigprocmask(SIG_SETMASK,0x7fffffffe22c,0) 4527 initial thread RET sigprocmask 0 4527 initial thread CALL sigreturn(0x7fffffffde50) 4527 initial thread RET sigreturn JUSTRETURN 4527 initial thread CALL fstat(0x1,0x7fffffffe1c0) 4527 initial thread STRU struct stat {dev=3D67174144, ino=3D128, mode=3D= crw--w---- , nlink=3D1, uid=3D1001, gid=3D4, rdev=3D128, atime=3D1291523109, stime=3D1= 291523110, ctime=3D 1291523110, birthtime=3D-1, size=3D0, blksize=3D4096, blocks=3D0, flags=3D0= x0 } 4527 initial thread RET fstat 0 4527 initial thread CALL ioctl(0x1,TIOCGETA,0x7fffffffe210) 4527 initial thread RET ioctl 0 4527 initial thread CALL write(0x1,0x8029b6000,0x1) 4527 initial thread GIO fd 1 wrote 1 byte Well, I'm glad to finally get to the bottom of this, and I want to apologize for the noise, but I think this is still a "gotcha" for new DTrace users, and I hope it can be noted somewhere (perhaps the DTrace sections on the FreeBSD wiki). -Brandon