[dtrace-discuss] run for cmd-line specified time ?

Bryan Cantrill
Tue, 15 May 2007 04:23:44 -0000

On Mon, May 14, 2007 at 08:47:10PM -0700, Peter Lawrence
wrote:
> I''ld like to be able to run my dtrace program for an amount of
seconds
> that I give as a command line argument, is there a standard cut-n-paste
> boilerplate method for this...?...   I can pass the amount at the end of
the
> command-line, and within my dtrace program it will be available as
"$1",
> but then what kind of probe can I write that will fire at $1 seconds plus
> the BEGIN time, and will cause all my END probes to fire.

	tick-1sec
	/i++ == $1/
	{
		exit(0);
	}


> what I don''t want to do is have a probe that calls exit(), because
the
> docs say that the END probes will not be invoked in this case, but
> I have END probes sprinkled throughout my program, which is a concatentaion
> of a lot of mostly separate programs, hence I need the END probes to
> trigger.

What docs are you looking at?  Calling exit() causes END to fire -- and
has for a long, long time.  From the exit() subsection of the Special Actions
section of the "Actions and Subroutines" chapter:

  When exit() is called, only DTrace actions already underway on other
  CPUs will be taken; no subsequent actions will be taken on any CPU.
  The only exception to this is the END probe, which will be called after
  the DTrace consumer has processed the exit() action and indicated that
  tracing should stop.

	- Bryan

--------------------------------------------------------------------------
Bryan Cantrill, Solaris Kernel Development.       http://blogs.sun.com/bmc