github.com/GoogleContainerTools/skaffold/v2@v2.13.2/integration/testdata/debug/java/scripts/check-jdwp.sh (about)

     1  #!/bin/sh
     2  # Check that JDWP connection exists using `jdb`.  `jdb` never returns
     3  # a non-zero exit code even if it fails to connect, but it does output
     4  # failure messages to stderr.
     5  
     6  if [ $# -eq 0 ]; then
     7    echo "use: $0 <jdwp-port>"
     8    exit 2
     9  fi
    10  
    11  # Attempt to attach and look for jdb attach failure; failure message is output to stdout. 
    12  if jdb -attach $1 < /dev/null 2>&1 | grep 'Unable to attach to target VM'; then
    13    # failure message found so failed to connect
    14    exit 1
    15  fi
    16  
    17  echo "connected to jdwp on port $1"
    18  exit 0