If I issue a long-running WSL command from a C# program, how do I terminate that Linux process programmatically? How do I identify the PID of the process in Linux so that I can issue a ‘kill’ command?
On Linux I usually use
ps xau | grep COMMAND.
ps xau prints a list of running processes, the output then goes to
grep which filters for lines matching the
COMMAND. The second column is the PID. If you run just
ps xau you get column labels at the top.
I hope this works on WSL, too!
Thanks for your response, airtower-luna. At first, I wasn’t sure that you had read my question correctly, but after looking closely at your answer, I believe this will do exactly what I want.