David Meisner wrote:
> Here's my code:
>
>
> #!/usr/bin/perl
>
> print "Welcome to the script\n";
>
> my $pid = fork();
>
> if(not defined $pid){
>
> #fork failed
> print 'Fork failed on resources :(\n';
>
> }elsif ($pid==0) {
>
> #In child process
>
> print "Starting DTrace\n";
> exec("dtrace -s pageTrace.d > traceOut.txt");
> print "DTrace finished\n";
My perl is a bit rusty, but exec is not going to return. Ever. I might
fail, but if it succeeds then it never returns. The following print will
only be executed in error.
>
> } else {
>
> #In parent process
>
> print "do work\n";
>
> #Stop the DTrace process
> kill('SIGINT',$pid);
You're racing to this signal. The aforementioned exec may or may not
have executed. You might kill the child process while it is still perl.
The child process may have even completed and returned already.
You are obviously calling dtrace because you want it to do something. Is
there a reason you can't have dtrace exit all by it's lonesome? Perhaps
the solution would be easier if you provided and outline of the dtrace
script you want to use.
donour
_______________________________________________
dtrace-discuss mailing list
[email protected]