blob: 30fc28ba95e45b1392c0a75d1fa77a5a0055d3f3 [file] [log] [blame]
#!/bin/bash
# Copyright (c) 2017 FH Dortmund and others
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Description:
# This script is used for listing thread names (if registered by pthread_setname_np)
# and thread IDs of all threads of a process by the process name.
# Right usage: ListThreads.sh <process_name>
# e.g. ListThreads.sh <process_name>
#
# Authors:
# M. Ozcelikors <mozcelikors@gmail.com>, FH Dortmund
#
args=("$@")
process_name=${args[0]}
if [ "$#" -ne 1 ]; then
echo "Entered arguments seem to be incorrect"
echo "Right usage: ListThreads.sh <process_name>"
echo "e.g. ListThreads.sh <process_name>"
else
pid=$(pgrep -f $process_name -o)
ps H -p $pid -o 'pid tid cmd comm'
fi