66#include "run-command.h"
77#include "string-list.h"
88#include "hashmap.h"
9+ #include "cleanup.h"
910
1011#if defined(HAVE_DEV_TTY ) || defined(GIT_WINDOWS_NATIVE )
1112
12- static void restore_term_on_signal (int sig )
13+ static void restore_term_on_signal (int signo UNUSED )
1314{
1415 restore_term ();
15- /* restore_term calls sigchain_pop_common */
16- raise (sig );
1716}
1817
1918#ifdef HAVE_DEV_TTY
@@ -136,7 +135,6 @@ void restore_term(void)
136135
137136 tcsetattr (term_fd , TCSAFLUSH , & old_term );
138137 close_term_fd ();
139- sigchain_pop_common ();
140138 reset_job_signals ();
141139}
142140
@@ -155,7 +153,7 @@ int save_term(enum save_term_flags flags)
155153 close_term_fd ();
156154 return -1 ;
157155 }
158- sigchain_push_common (restore_term_on_signal );
156+ cleanup_register (restore_term_on_signal );
159157 /*
160158 * If job control is disabled then the shell will have set the
161159 * disposition of SIGTSTP to SIG_IGN.
@@ -197,7 +195,6 @@ static int disable_bits(enum save_term_flags flags, tcflag_t bits)
197195 if (!tcsetattr (term_fd , TCSAFLUSH , & t ))
198196 return 0 ;
199197
200- sigchain_pop_common ();
201198 reset_job_signals ();
202199 close_term_fd ();
203200 return -1 ;
@@ -272,8 +269,6 @@ void restore_term(void)
272269 return ;
273270 }
274271
275- sigchain_pop_common ();
276-
277272 if (hconin == INVALID_HANDLE_VALUE )
278273 return ;
279274
@@ -308,7 +303,7 @@ int save_term(enum save_term_flags flags)
308303
309304 GetConsoleMode (hconin , & cmode_in );
310305 use_stty = 0 ;
311- sigchain_push_common (restore_term_on_signal );
306+ cleanup_register (restore_term_on_signal );
312307 return 0 ;
313308error :
314309 CloseHandle (hconin );
@@ -359,7 +354,6 @@ static int disable_bits(enum save_term_flags flags, DWORD bits)
359354 if (!SetConsoleMode (hconin , cmode_in & ~bits )) {
360355 CloseHandle (hconin );
361356 hconin = INVALID_HANDLE_VALUE ;
362- sigchain_pop_common ();
363357 return -1 ;
364358 }
365359
0 commit comments