I'd like programming a simple firewall.
This program should read a rules file, and every second check all the files /proc/[1-9][0-9]*/exe (executable file name) and /proc/[1-9][0-9]*/stat (process name). If that pair executable name/process appear in the rules file opening the relative ports. When the process disappears close them. I'll use iptables for this.
How can I list all the /proc/[1-9][0-9]*$ files in the most portable way?