dos2unix: tiny shrink
[oweals/busybox.git] / shell / hush.c
index 820fd888d6cee67068bff25a014c2aaf09befead..c61607dd39f24f91b0ca19c3a0b065367670a1b2 100644 (file)
@@ -460,6 +460,9 @@ enum { run_list_level = 0 };
 #endif
 #define charmap          (G.charmap         )
 #define user_input_buf   (G.user_input_buf  )
+#define INIT_G() do { \
+       SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+} while (0)
 
 
 #define B_CHUNK  100
@@ -696,16 +699,6 @@ static const struct built_in_command bltins[] = {
 
 #if ENABLE_HUSH_JOB
 
-/* move to libbb? */
-static void signal_SA_RESTART(int sig, void (*handler)(int))
-{
-       struct sigaction sa;
-       sa.sa_handler = handler;
-       sa.sa_flags = SA_RESTART;
-       sigemptyset(&sa.sa_mask);
-       sigaction(sig, &sa, NULL);
-}
-
 /* Signals are grouped, we handle them in batches */
 static void set_fatal_sighandler(void (*handler)(int))
 {
@@ -795,11 +788,8 @@ static void handler_ctrl_z(int sig)
 static void sigexit(int sig) ATTRIBUTE_NORETURN;
 static void sigexit(int sig)
 {
-       sigset_t block_all;
-
        /* Disable all signals: job control, SIGPIPE, etc. */
-       sigfillset(&block_all);
-       sigprocmask(SIG_SETMASK, &block_all, NULL);
+       sigprocmask_allsigs(SIG_BLOCK);
 
        if (interactive_fd)
                tcsetpgrp(interactive_fd, saved_tty_pgrp);
@@ -808,12 +798,7 @@ static void sigexit(int sig)
        if (sig <= 0)
                _exit(- sig);
 
-       /* Enable only this sig and kill ourself with it */
-       signal(sig, SIG_DFL);
-       sigdelset(&block_all, sig);
-       sigprocmask(SIG_SETMASK, &block_all, NULL);
-       raise(sig);
-       _exit(1); /* Should not reach it */
+       kill_myself_with_sig(sig); /* does not return */
 }
 
 /* Restores tty foreground process group, and exits. */
@@ -2117,7 +2102,7 @@ static int run_list(struct pipe *pi)
 #if ENABLE_FEATURE_SH_STANDALONE
                nofork_save.saved = 0; /* in case we will run a nofork later */
 #endif
-               signal_SA_RESTART(SIGTSTP, handler_ctrl_z);
+               signal_SA_RESTART_empty_mask(SIGTSTP, handler_ctrl_z);
                signal(SIGINT, handler_ctrl_c);
        }
 #endif /* JOB */
@@ -3783,7 +3768,7 @@ int hush_main(int argc, char **argv)
        char **e;
        struct variable *cur_var;
 
-       PTR_TO_GLOBALS = xzalloc(sizeof(G));
+       INIT_G();
 
        /* Deal with HUSH_VERSION */
        shell_ver = const_shell_ver; /* copying struct here */