aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-04-06 10:21:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-04-06 10:21:42 +0000
commitd3f973eab29786a45cfebeba5d32b3647c343737 (patch)
tree8fa2ee78b61bea811ce07493cc6cd44475e7a975 /shell
parenta0e65120b5f4b437b09b117c829f145049c34bba (diff)
downloadbusybox-w32-d3f973eab29786a45cfebeba5d32b3647c343737.tar.gz
busybox-w32-d3f973eab29786a45cfebeba5d32b3647c343737.tar.bz2
busybox-w32-d3f973eab29786a45cfebeba5d32b3647c343737.zip
hush: mark SIGHUP TODOs better; don't disable SIGHUP for now,
small tweaks to comments
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/shell/hush.c b/shell/hush.c
index ba2081d1b..04853137b 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -894,7 +894,8 @@ static int check_and_run_traps(int sig)
894//TODO 894//TODO
895// case SIGHUP: ... 895// case SIGHUP: ...
896// break; 896// break;
897 default: /* SIGTERM, SIGQUIT, SIGTTIN, SIGTTOU, SIGTSTP */ 897 default: /* ignored: */
898 /* SIGTERM, SIGQUIT, SIGTTIN, SIGTTOU, SIGTSTP */
898 break; 899 break;
899 } 900 }
900 } 901 }
@@ -4940,7 +4941,7 @@ static void block_signals(int second_time)
4940 mask = 0 4941 mask = 0
4941 | (1 << SIGQUIT) 4942 | (1 << SIGQUIT)
4942 | (1 << SIGTERM) 4943 | (1 << SIGTERM)
4943 | (1 << SIGHUP) 4944//TODO | (1 << SIGHUP)
4944#if ENABLE_HUSH_JOB 4945#if ENABLE_HUSH_JOB
4945 | (1 << SIGTTIN) | (1 << SIGTTOU) | (1 << SIGTSTP) 4946 | (1 << SIGTTIN) | (1 << SIGTTOU) | (1 << SIGTSTP)
4946#endif 4947#endif
@@ -4983,7 +4984,7 @@ static void maybe_set_to_sigexit(int sig)
4983 signal(sig, handler); 4984 signal(sig, handler);
4984 } 4985 }
4985} 4986}
4986/* Set handlers to restore tty pgrm and exit */ 4987/* Set handlers to restore tty pgrp and exit */
4987static void set_fatal_handlers(void) 4988static void set_fatal_handlers(void)
4988{ 4989{
4989 /* We _must_ restore tty pgrp on fatal signals */ 4990 /* We _must_ restore tty pgrp on fatal signals */
@@ -4998,8 +4999,9 @@ static void set_fatal_handlers(void)
4998 /* bash 3.2 seems to handle these just like 'fatal' ones */ 4999 /* bash 3.2 seems to handle these just like 'fatal' ones */
4999 maybe_set_to_sigexit(SIGPIPE); 5000 maybe_set_to_sigexit(SIGPIPE);
5000 maybe_set_to_sigexit(SIGALRM); 5001 maybe_set_to_sigexit(SIGALRM);
5002//TODO: disable and move down when proper SIGHUP handling is added
5001 maybe_set_to_sigexit(SIGHUP ); 5003 maybe_set_to_sigexit(SIGHUP );
5002 /* if we are interactive, SIGTERM and SIGINT are masked. 5004 /* if we are interactive, [SIGHUP,] SIGTERM and SIGINT are masked.
5003 * if we aren't interactive... but in this case 5005 * if we aren't interactive... but in this case
5004 * we never want to restore pgrp on exit, and this fn is not called */ 5006 * we never want to restore pgrp on exit, and this fn is not called */
5005 /*maybe_set_to_sigexit(SIGTERM);*/ 5007 /*maybe_set_to_sigexit(SIGTERM);*/
@@ -5075,8 +5077,8 @@ int hush_main(int argc, char **argv)
5075#endif 5077#endif
5076 5078
5077 /* Shell is non-interactive at first. We need to call 5079 /* Shell is non-interactive at first. We need to call
5078 * block_signals(0) if we are going to execute "sh script", 5080 * block_signals(0) if we are going to execute "sh <script>",
5079 * "sh -c cmds" or login shell's /etc/profile and friends. 5081 * "sh -c <cmds>" or login shell's /etc/profile and friends.
5080 * If we later decide that we are interactive, we run block_signals(0) 5082 * If we later decide that we are interactive, we run block_signals(0)
5081 * (or re-run block_signals(1) if we ran block_signals(0) before) 5083 * (or re-run block_signals(1) if we ran block_signals(0) before)
5082 * in order to intercept (more) signals. 5084 * in order to intercept (more) signals.
@@ -5125,11 +5127,11 @@ int hush_main(int argc, char **argv)
5125 case '?': 5127 case '?':
5126 G.last_return_code = xatoi_u(optarg); 5128 G.last_return_code = xatoi_u(optarg);
5127 break; 5129 break;
5128#if ENABLE_HUSH_LOOPS 5130# if ENABLE_HUSH_LOOPS
5129 case 'D': 5131 case 'D':
5130 G.depth_of_loop = xatoi_u(optarg); 5132 G.depth_of_loop = xatoi_u(optarg);
5131 break; 5133 break;
5132#endif 5134# endif
5133 case 'R': 5135 case 'R':
5134 case 'V': 5136 case 'V':
5135 set_local_var(xstrdup(optarg), 0, opt == 'R'); 5137 set_local_var(xstrdup(optarg), 0, opt == 'R');
@@ -5178,8 +5180,8 @@ int hush_main(int argc, char **argv)
5178 if (argv[optind]) { 5180 if (argv[optind]) {
5179 FILE *input; 5181 FILE *input;
5180 /* 5182 /*
5181 * Non-interactive "bash <script>" sources $BASH_ENV here 5183 * "bash <script>" (which is never interactive (unless -i?))
5182 * (without scanning $PATH). 5184 * sources $BASH_ENV here (without scanning $PATH).
5183 * If called as sh, does the same but with $ENV. 5185 * If called as sh, does the same but with $ENV.
5184 */ 5186 */
5185 debug_printf("running script '%s'\n", argv[optind]); 5187 debug_printf("running script '%s'\n", argv[optind]);
@@ -5212,6 +5214,9 @@ int hush_main(int argc, char **argv)
5212 if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) { 5214 if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
5213 G.saved_tty_pgrp = tcgetpgrp(STDIN_FILENO); 5215 G.saved_tty_pgrp = tcgetpgrp(STDIN_FILENO);
5214 debug_printf("saved_tty_pgrp:%d\n", G.saved_tty_pgrp); 5216 debug_printf("saved_tty_pgrp:%d\n", G.saved_tty_pgrp);
5217//TODO: "interactive" and "have job control" are two different things.
5218//If tcgetpgrp fails here, "have job control" is false, but "interactive"
5219//should stay on! Currently, we mix these into one.
5215 if (G.saved_tty_pgrp >= 0) { 5220 if (G.saved_tty_pgrp >= 0) {
5216 /* try to dup stdin to high fd#, >= 255 */ 5221 /* try to dup stdin to high fd#, >= 255 */
5217 G_interactive_fd = fcntl(STDIN_FILENO, F_DUPFD, 255); 5222 G_interactive_fd = fcntl(STDIN_FILENO, F_DUPFD, 255);