DTrace: Sending ^C while running script produces no output

Brandon Gooch jamesbrandongooch at gmail.com
Sun Dec 5 05:00:12 UTC 2010


On Sat, Dec 4, 2010 at 3:27 PM, Brandon Gooch
<jamesbrandongooch at gmail.com> wrote:
> On Sat, Dec 4, 2010 at 2:32 PM, Andriy Gapon <avg at freebsd.org> 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 at d820:~$ sudo dtrace -n 'syscall:::entry { @num[execname] = count(); }'
>>> dtrace: description 'syscall:::entry ' matched 514 probes
>>> ^C
>>
>> BTW, sudo might play a role here...  Just 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=0x80065d0d0 mask=0x0 code=0x0
  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=67174144, ino=120, mode=crw--w----
, nlink=1, uid=1001, gid=4, rdev=120, atime=1291504111, stime=1291504111, ctime=
1291504111, birthtime=-1, size=0, blksize=4096, blocks=0, flags=0x0 }
  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=0x80065d0d0 mask=0x0 code=0x0
  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=0x80065d0d0 mask=0x0 code=0x0
  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=0x80065d0d0 mask=0x0 code=0x0
  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=67174144, ino=128, mode=crw--w----
, nlink=1, uid=1001, gid=4, rdev=128, atime=1291523109, stime=1291523110, ctime=
1291523110, birthtime=-1, size=0, blksize=4096, blocks=0, flags=0x0 }
  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


More information about the freebsd-hackers mailing list