{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2shell - Ignore interactive and job-control signals...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 /* Keep track of attributes of the shell. */ #include <sys/types.h> #include <termios.h> #include <unistd.h> pid_t shell_pgid struct termios shell_tmodes int shell_terminal int shell_is_interactive /* Make sure the shell is running interactively as the foreground job before proceeding. */ void init_shell () { /* See if we are running interactively. */ shell_terminal = STDIN_FILENO shell_is_interactive = isatty (shell_terminal) if (shell_is_interactive) { /* Loop until we are in the foreground. */ while (tcgetpgrp (shell_terminal) != (shell_pgid = getpgrp ())) kill (- shell_pgid, SIGTTIN)
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* Ignore interactive and job-control signals. */ signal (SIGINT, SIG_IGN) signal (SIGQUIT, SIG_IGN) signal (SIGTSTP, SIG_IGN) signal (SIGTTIN, SIG_IGN) signal (SIGTTOU, SIG_IGN) signal (SIGCHLD, SIG_IGN) /* Put ourselves in our own process group. */ shell_pgid = getpid () if (setpgid (shell_pgid, shell_pgid) < 0) { perror ("Couldn't put the shell in its own process group") exit (1) } /* Grab control of the terminal. */ tcsetpgrp (shell_terminal, shell_pgid) /* Save default terminal attributes for shell. */ tcgetattr (shell_terminal, &shell_tmodes) } }...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern