I am starting a perl script that runs forever listening to a port. It is invoked as such:
system("perl home/root/portlistener.pl 100 &");
But now, I have a new requirement to implement a button that is supposed to "close" the port and free up resources. So, when the user taps the button on the resistive touch display, I should kill the perl process. But, how do I kill the perl process when I don't have the PID?
I know you can do something like the script below to echo the PID:
perl home/root/portlistener.pl 100 & echo$!
Or I could run something like:
ps | grep portlistener
But how do I retrieve the PID real-time from within my Arduino code?