removed -p for BSD support. Fixed termination problem.