Hello, i am converting an bash code to golang code
If i run /usr/bin/getmykey &> /dev/null and i want to kill the process then in bash i will run this : ps aux | grep getmykey | grep -v grep | awk '{print "kill -9 " $2;system("kill -9 " $2)}'
I don’t want to use bash, i want to use an compiled language and i already written code in go just this part isn’t written.
Is there any simple way to kill the process via Golang ?
There might or might not be abstractions or libraries available that give you a simple function to call to get a list of pids for a given binary name.
Though shelling out to ps aux, scanning the lines for a given pattern, shelling to kill -p is probably much quicker written than it would take to find libraries doing the thing for you.