From effd3920184799a610d5f7b48b28ccd4098e4945 Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Mon, 28 Jul 2025 03:49:42 +1000 Subject: [PATCH] fix for task kill grep problem --- .../punk/mix/commandset/scriptwrap-0.1.0.tm | 2 +- src/make.tcl | 21 ++++++++++++++----- .../mix/commandset/scriptwrap-999999.0a1.0.tm | 2 +- .../custom/_project/punk.basic/src/make.tcl | 21 ++++++++++++++----- .../punk/mix/commandset/scriptwrap-0.1.0.tm | 2 +- .../_project/punk.project-0.1/src/make.tcl | 21 ++++++++++++++----- .../punk/mix/commandset/scriptwrap-0.1.0.tm | 2 +- .../_project/punk.shell-0.1/src/make.tcl | 21 ++++++++++++++----- .../punk/mix/commandset/scriptwrap-0.1.0.tm | 2 +- 9 files changed, 69 insertions(+), 25 deletions(-) diff --git a/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm b/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm index 06b145de..24168483 100644 --- a/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm +++ b/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm @@ -1250,7 +1250,7 @@ namespace eval punk::mix::commandset::scriptwrap { puts stdout "overwriting $output_file because -force = $opt_force" } } - + set fdt [open $wrapper_template r] fconfigure $fdt -translation binary diff --git a/src/make.tcl b/src/make.tcl index 37f36a9a..ed326313 100644 --- a/src/make.tcl +++ b/src/make.tcl @@ -2926,16 +2926,27 @@ foreach vfstail $vfs_tails { #killing process doesn't apply to .kit build if {$rtname ne "-"} { + #exec $pscmd | grep $targetkit ;#wrong - fails on at least some OSes because grep itself is in the list + #exec ps | grep $targetkit | grep -v grep ;#exclude grep process if {![catch { - exec $pscmd | grep $targetkit - } still_running]} { - set still_running_lines [split [string trim $still_running] \n] + exec $pscmd + } ps_lines]} { + #we will process without grep for for now - may not be avail on windows? + set still_running_lines [list] + foreach ln [split [string trim $ps_lines] \n] { + if {[string match "* grep *" $ln]} {continue} + if {[string match "*$targetkit*" $ln]} { + lappend still_running_lines $ln + } + } + + #set still_running_lines [split [string trim $still_running] \n] puts stdout "found ([llength $still_running_lines]) $targetkit instances still running\n" set count_killed 0 set num_to_kill [llength $still_running_lines] - foreach ln [split $still_running \n] { + foreach ln $still_running_lines { puts stdout " $ln" - + if {$::tcl_platform(platform) eq "windows"} { set pid [lindex $ln 1] if {$forcekill} { diff --git a/src/modules/punk/mix/commandset/scriptwrap-999999.0a1.0.tm b/src/modules/punk/mix/commandset/scriptwrap-999999.0a1.0.tm index 8a58f78e..c5f6b9b5 100644 --- a/src/modules/punk/mix/commandset/scriptwrap-999999.0a1.0.tm +++ b/src/modules/punk/mix/commandset/scriptwrap-999999.0a1.0.tm @@ -1250,7 +1250,7 @@ namespace eval punk::mix::commandset::scriptwrap { puts stdout "overwriting $output_file because -force = $opt_force" } } - + set fdt [open $wrapper_template r] fconfigure $fdt -translation binary diff --git a/src/project_layouts/custom/_project/punk.basic/src/make.tcl b/src/project_layouts/custom/_project/punk.basic/src/make.tcl index 37f36a9a..ed326313 100644 --- a/src/project_layouts/custom/_project/punk.basic/src/make.tcl +++ b/src/project_layouts/custom/_project/punk.basic/src/make.tcl @@ -2926,16 +2926,27 @@ foreach vfstail $vfs_tails { #killing process doesn't apply to .kit build if {$rtname ne "-"} { + #exec $pscmd | grep $targetkit ;#wrong - fails on at least some OSes because grep itself is in the list + #exec ps | grep $targetkit | grep -v grep ;#exclude grep process if {![catch { - exec $pscmd | grep $targetkit - } still_running]} { - set still_running_lines [split [string trim $still_running] \n] + exec $pscmd + } ps_lines]} { + #we will process without grep for for now - may not be avail on windows? + set still_running_lines [list] + foreach ln [split [string trim $ps_lines] \n] { + if {[string match "* grep *" $ln]} {continue} + if {[string match "*$targetkit*" $ln]} { + lappend still_running_lines $ln + } + } + + #set still_running_lines [split [string trim $still_running] \n] puts stdout "found ([llength $still_running_lines]) $targetkit instances still running\n" set count_killed 0 set num_to_kill [llength $still_running_lines] - foreach ln [split $still_running \n] { + foreach ln $still_running_lines { puts stdout " $ln" - + if {$::tcl_platform(platform) eq "windows"} { set pid [lindex $ln 1] if {$forcekill} { diff --git a/src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm b/src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm index 06b145de..24168483 100644 --- a/src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm +++ b/src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm @@ -1250,7 +1250,7 @@ namespace eval punk::mix::commandset::scriptwrap { puts stdout "overwriting $output_file because -force = $opt_force" } } - + set fdt [open $wrapper_template r] fconfigure $fdt -translation binary diff --git a/src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl b/src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl index 37f36a9a..ed326313 100644 --- a/src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl +++ b/src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl @@ -2926,16 +2926,27 @@ foreach vfstail $vfs_tails { #killing process doesn't apply to .kit build if {$rtname ne "-"} { + #exec $pscmd | grep $targetkit ;#wrong - fails on at least some OSes because grep itself is in the list + #exec ps | grep $targetkit | grep -v grep ;#exclude grep process if {![catch { - exec $pscmd | grep $targetkit - } still_running]} { - set still_running_lines [split [string trim $still_running] \n] + exec $pscmd + } ps_lines]} { + #we will process without grep for for now - may not be avail on windows? + set still_running_lines [list] + foreach ln [split [string trim $ps_lines] \n] { + if {[string match "* grep *" $ln]} {continue} + if {[string match "*$targetkit*" $ln]} { + lappend still_running_lines $ln + } + } + + #set still_running_lines [split [string trim $still_running] \n] puts stdout "found ([llength $still_running_lines]) $targetkit instances still running\n" set count_killed 0 set num_to_kill [llength $still_running_lines] - foreach ln [split $still_running \n] { + foreach ln $still_running_lines { puts stdout " $ln" - + if {$::tcl_platform(platform) eq "windows"} { set pid [lindex $ln 1] if {$forcekill} { diff --git a/src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm b/src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm index 06b145de..24168483 100644 --- a/src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm +++ b/src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/mix/commandset/scriptwrap-0.1.0.tm @@ -1250,7 +1250,7 @@ namespace eval punk::mix::commandset::scriptwrap { puts stdout "overwriting $output_file because -force = $opt_force" } } - + set fdt [open $wrapper_template r] fconfigure $fdt -translation binary diff --git a/src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl b/src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl index 37f36a9a..ed326313 100644 --- a/src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl +++ b/src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl @@ -2926,16 +2926,27 @@ foreach vfstail $vfs_tails { #killing process doesn't apply to .kit build if {$rtname ne "-"} { + #exec $pscmd | grep $targetkit ;#wrong - fails on at least some OSes because grep itself is in the list + #exec ps | grep $targetkit | grep -v grep ;#exclude grep process if {![catch { - exec $pscmd | grep $targetkit - } still_running]} { - set still_running_lines [split [string trim $still_running] \n] + exec $pscmd + } ps_lines]} { + #we will process without grep for for now - may not be avail on windows? + set still_running_lines [list] + foreach ln [split [string trim $ps_lines] \n] { + if {[string match "* grep *" $ln]} {continue} + if {[string match "*$targetkit*" $ln]} { + lappend still_running_lines $ln + } + } + + #set still_running_lines [split [string trim $still_running] \n] puts stdout "found ([llength $still_running_lines]) $targetkit instances still running\n" set count_killed 0 set num_to_kill [llength $still_running_lines] - foreach ln [split $still_running \n] { + foreach ln $still_running_lines { puts stdout " $ln" - + if {$::tcl_platform(platform) eq "windows"} { set pid [lindex $ln 1] if {$forcekill} { diff --git a/src/vfs/_vfscommon.vfs/modules/punk/mix/commandset/scriptwrap-0.1.0.tm b/src/vfs/_vfscommon.vfs/modules/punk/mix/commandset/scriptwrap-0.1.0.tm index 06b145de..24168483 100644 --- a/src/vfs/_vfscommon.vfs/modules/punk/mix/commandset/scriptwrap-0.1.0.tm +++ b/src/vfs/_vfscommon.vfs/modules/punk/mix/commandset/scriptwrap-0.1.0.tm @@ -1250,7 +1250,7 @@ namespace eval punk::mix::commandset::scriptwrap { puts stdout "overwriting $output_file because -force = $opt_force" } } - + set fdt [open $wrapper_template r] fconfigure $fdt -translation binary