In: Computer Science
Write shell script code that shows all threads created by a given process. The user will provide the process identifier of that process.
#!/bin/bash
while [[ $REPLY != x ]]; do
clear
echo -e "Launch utilities:\n 1. Process Tree\n 2. Process States\n 3. Threads\n"
read -p "Enter selection [1-3], or type x to exit: " REPLY
if [ $REPLY == 1 ]; then
echo -e "\n"
#identify a command that displays the tree of
processes in Linux
#identify the options of the command you have found that meet the
requirements described in section "Process Tree" of the description
of Homework 03
#put the command here, followed by the options. For example, if the
command is called displayprocesstree, and the options are -a, -b,
and -c, the command would appear as follows:
# displayprocesstree -abc
read void
clear
fi
if [ $REPLY == 2 ]; then
#identify the command that displays a list of processes on the
system. identify the options of that command that can include the
state of each process in the output
read void
clear
fi
if [ $REPLY == 3 ]; then
#display a string that asks the user to enter the pid of one of the
processes
#read a pid from the user onto a variable
# display the threads created by that process
read void
clear
fi
done
#!/bin/bash
while [[ $REPLY != x ]]; do
clear
echo -e "Launch utilities:\n 1. Process Tree\n 2. Process States\n 3. Threads\n"
read -p "Enter selection [1-3], or type x to exit: " REPLY
if [ $REPLY == 1 ]; then
echo -e "\n"
pstree -psa $$
ps -aef --forest
read void
clear
fi
if [ $REPLY == 2 ]; then
ps u
read void
clear
fi
if [ $REPLY == 3 ]; then
read -p "Enter PID: " p_id
ps -T -p $p_id
read void
clear
fi
if you have any doubt then please ask me without any hesitation
in the comment section below , if you like my answer then please
thumbs up for the answer , before giving thumbs down please discuss
the question it may possible that we may understand the question
different way and we can edit and change the answers if you argue,
thanks :)