diff options
author | mg147109 <none@none> | 2006-06-15 04:45:02 -0700 |
---|---|---|
committer | mg147109 <none@none> | 2006-06-15 04:45:02 -0700 |
commit | 2b51d29a0450e65005bfc1c43520e6ebb13778ce (patch) | |
tree | 35d8c8987e123865324ee9e30cdc275926225cd8 /usr | |
parent | 1d452cf5123cb6ac0a013a4dbd4dcceeb0da314d (diff) | |
download | illumos-joyent-2b51d29a0450e65005bfc1c43520e6ebb13778ce.tar.gz |
6230795 C-Shell leaves process running after termination.
Diffstat (limited to 'usr')
-rw-r--r-- | usr/src/cmd/csh/sh.c | 30 | ||||
-rw-r--r-- | usr/src/cmd/csh/sh.proc.c | 15 |
2 files changed, 45 insertions, 0 deletions
diff --git a/usr/src/cmd/csh/sh.c b/usr/src/cmd/csh/sh.c index f03ffbbaf6..da000b4c14 100644 --- a/usr/src/cmd/csh/sh.c +++ b/usr/src/cmd/csh/sh.c @@ -55,6 +55,10 @@ extern gid_t getegid(), getgid(); extern uid_t geteuid(), getuid(); extern tchar **strblktotsblk(/* char **, int */); +extern void hupforegnd(void); +void interactive_hup(void); +void interactive_login_hup(void); + void importpath(tchar *); void srccat(tchar *, tchar *); void srccat_inlogin(tchar *, tchar *); @@ -441,6 +445,17 @@ main(int c, char **av) (void) signal(SIGINT, pintr); (void) sigblock(sigmask(SIGINT)); (void) signal(SIGTERM, SIG_IGN); + + /* + * Explicitly terminate foreground jobs and exit if we are + * interactive shell + */ + if (loginsh) { + (void) signal(SIGHUP, interactive_login_hup); + } else { + (void) signal(SIGHUP, interactive_hup); + } + if (quitit == 0 && arginp == 0) { (void) signal(SIGTSTP, SIG_IGN); (void) signal(SIGTTIN, SIG_IGN); @@ -837,6 +852,21 @@ phup(void) exit(1); } +void +interactive_hup(void) +{ + hupforegnd(); + exit(1); +} + +void +interactive_login_hup(void) +{ + rechist(); + hupforegnd(); + exit(1); +} + tchar *jobargv[2] = { S_jobs /* "jobs" */, 0 }; /* * Catch an interrupt, e.g. during lexical input. diff --git a/usr/src/cmd/csh/sh.proc.c b/usr/src/cmd/csh/sh.proc.c index d0d043b3db..298c2e718a 100644 --- a/usr/src/cmd/csh/sh.proc.c +++ b/usr/src/cmd/csh/sh.proc.c @@ -1288,3 +1288,18 @@ okpcntl(void) if (tpgrp == 0) error("No job control in subshells"); } + +void +hupforegnd(void) +{ + struct process *pp; + int omask; + + omask = sigblock(sigmask(SIGCHLD)); + for (pp = (&proclist)->p_next; pp != PNULL; pp = pp->p_next) + if (pp->p_pid > 0) { + if (pp->p_flags & PFOREGND) + (void) kill(pp->p_pid, SIGHUP); + } + (void) sigsetmask(omask); +} |