refactored to use proc logic on other possible platforms like bsd and solaris