#!/bin/bash
COUNT=10
TIMEOUT=4s

for i in $(seq 1 $COUNT); do
    $@ &
done
sleep $TIMEOUT
list_descendants ()
{
  local children=$(ps -o pid= --ppid "$1")
  for pid in $children; do list_descendants "$pid"; done
  echo "$children"
}
kill $(list_descendants $$)
