updated with chaitanyas changes to print group wise and added child signal handler for graceful exit.