I am given a program that runs until it is stopped using ctrl + c. I need to find the pid of this process and then output information like user time, system time , and total time using a bash script. It is my understanding that in oder to do this I need to run the process and then stop it inside the script and after I stop the program I am able to find the information. I am having issues with stopping the process inside the script.
#!/bin/bash
clarg="$1"
if [ "$clarg" == "cpu" ] ; then
gcc -o cpu cpu.c
./cpu
#This is where I'm lost and tried this out from online but
#didn't work for me
trap "exit" INT
while :
do
sl -e
done
#Commands to find PID info below.