- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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 portlistenerBut how do I retrieve the PID real-time from within my Arduino code?
Once I retrieve the PID, I can issue a
system("kill xxx");to kill the process.
Or is there a much better way?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Solved via a call to another PERL script that uses the same port number (shown as 100 in the example above).
perl home/root/stoplistener.pl 100
Inspiration for stoplistener.pl can be found http://forums.devshed.com/perl-programming-6/process-list-script-perl-linux-872135.html here and http://http//stackoverflow.com/questions/3129238/how-do-i-stop-a-process-running-using-perl here.
Ultimately relied on this command to list out the PIDs:
ps | grep "portlistener 100"
Regards,
Gavin
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Solved via a call to another PERL script that uses the same port number (shown as 100 in the example above).
perl home/root/stoplistener.pl 100
Inspiration for stoplistener.pl can be found http://forums.devshed.com/perl-programming-6/process-list-script-perl-linux-872135.html here and http://http//stackoverflow.com/questions/3129238/how-do-i-stop-a-process-running-using-perl here.
Ultimately relied on this command to list out the PIDs:
ps | grep "portlistener 100"
Regards,
Gavin

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page