The program below starts four processes. The task first waits for the last process to start executing and then waits for the first process to terminate. At that point, the parent process forcibly terminates all forked processes that have not yet completed.
program automatic test;
initial begin
do_n_ways;
end
task do_n_ways;
process job[1:4];
for(int i=1;i<=4;i++)
fork
automatic int j = i;
job[j] = process::self();
$display("process %d starting...",j);
if(j==2) begin
#100 $display("delay 2ns");
end
join_none
for(int j = 1;j<=4;j++) begin //wait for all process starting
wait(job[j] != null);
end
job[1].await(); //wait for first process finish
for(int j=1;j<=4;j++) begin
if(job[j].status != process::FINISHED) begin
job[j].kill();
$display("process %d killed...",j);
end
end
endtask
endprogram
It appears that process #2 never gets killed since I never see "process 2 killed..." Why does this process continue to run?