Skip to content

Commit

Permalink
use less utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
clbx committed Jul 12, 2024
1 parent eb8411a commit 9646fe8
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,37 @@ type PodOptions struct {
cmd []string
}

// var script = `
// base_processes=$(ps aux | grep -E "ash|bash|sh" | grep -v grep | wc -l)
// echo "Processes: $base_processes"
// sleep 2

// while :; do
//
// shell_processes=$(ps aux | grep -E "ash|bash|sh" | grep -v grep | wc -l)
// if [ "$shell_processes" -gt "$base_processes" ]; then
// echo "Found an additional process"
// while [ "$shell_processes" -gt "$base_processes" ]; do
// sleep 2
// shell_processes=$(ps aux | grep -E "ash|bash|sh" | grep -v grep | wc -l)
// done
// exit 0
// fi
//
// done
// `
var script = `
base_processes=$(ps aux | grep -E "ash|bash|sh" | grep -v grep | wc -l)
base_processes=$(ls /proc | grep -E '^[0-9]+$' | xargs -I {} sh -c 'cat /proc/{}/comm 2>/dev/null' | grep -E "ash|bash|sh" | wc -l)
echo "Processes: $base_processes"
sleep 2
while :; do
shell_processes=$(ps aux | grep -E "ash|bash|sh" | grep -v grep | wc -l)
shell_processes=$(ls /proc | grep -E '^[0-9]+$' | xargs -I {} sh -c 'cat /proc/{}/comm 2>/dev/null' | grep -E "ash|bash|sh" | wc -l)
if [ "$shell_processes" -gt "$base_processes" ]; then
echo "Found an additional process"
while [ "$shell_processes" -gt "$base_processes" ]; do
sleep 2
shell_processes=$(ps aux | grep -E "ash|bash|sh" | grep -v grep | wc -l)
shell_processes=$(ls /proc | grep -E '^[0-9]+$' | xargs -I {} sh -c 'cat /proc/{}/comm 2>/dev/null' | grep -E "ash|bash|sh" | wc -l)
done
exit 0
fi
Expand Down

0 comments on commit 9646fe8

Please sign in to comment.