modified the tcsetpgrp and waitpid, now may work and make some sense..