- signal(SIGINT, quit);
-}
-/*
- * This routine copies one structure to another
- */
-cpy_st(s1, s2, size)
-reg int *s1, *s2, size; {
-
- size /= 2;
- while (size--)
- *s1++ = *s2++;
-}
-/*
- * This routine forks off a shell. It uses the users login shell
- */
-shell_out() {
-
- static char *shell = NULL;
-
- printline();
- if (shell == NULL)
- shell = shell_in();
- fflush(stdout);
- if (!fork()) {
- signal(SIGINT, SIG_DFL);
- execsh(shell);
- }
- ignoresigs();
- wait();
- resetsigs();
- putchar('\n');
- printline();
-}
-/*
- * This routine looks up the users login shell
- */
-# include <sys/types.h>
-# include <pwd.h>
-
-char *getenv();
-
-char *
-shell_in() {
-
- reg struct passwd *pp;
- reg char *sp;
-
- if ((sp = getenv("SHELL")) == NULL) {
- pp = getpwuid(getuid());
- if (pp->pw_shell[0] != '\0')
- return pp->pw_shell;
- else
- return shell_def;
- /*return (*(pp->pw_shell) != '\0' ? pp->pw_shell : shell_def);*/
- }
- return sp;
-}
-/*
- * This routine sets things up to ignore all the signals.
- */
-ignoresigs() {
-
- reg int i;
-
- for (i = 0; i < NSIG; i++)
- signal(i, SIG_IGN);
-}
-/*
- * This routine sets up things as they were before.
- */
-resetsigs() {
-
- reg int i;
-
- for (i = 0; i < NSIG; i++)
- signal(i, SIG_DFL);
- signal(SIGINT, quit);