use Tk; my $stop :shared=0; #...create Tk window $parent-> Button(-text=>"stop", -command=>sub{$stop=1;}); $parent-> Button(-text=>"run", -command=>\&run_thread); sub run_thread { async{ &process; }; } sub process { open(CTFIND, "sometool find $path -print |"); while() { if($stop eq 1) { #close command take a while #close CTFIND; This command will take a while to #close. It is cause any problem without close #pipe line? print"End Task\n"; return; } chomp; #..... some date process } close CTFIND; return; }