/* * Functions you may use for your shell. * See FAQ Question 4. * * CS 3214 Fall 2011, Godmar Back. */ /** * Assign ownership of ther terminal to process group * pgrp, restoring its terminal state if provided. * * Before printing a new prompt, the shell should * invoke this function with its own process group * id (obtained on startup via getpgrp()) and a * sane terminal state (obtained on startup via * esh_sys_tty_init()). */ static void give_terminal_to(pid_t pgrp, struct termios *pg_tty_state) { esh_signal_block(SIGTTOU); int rc = tcsetpgrp(esh_sys_tty_getfd(), pgrp); if (rc == -1) esh_sys_fatal_error("tcsetpgrp: "); if (pg_tty_state) esh_sys_tty_restore(pg_tty_state); esh_signal_unblock(SIGTTOU); }