su: Handle more signals gracefully
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
81e1fdf81e
commit
1f6a0db188
@ -14,10 +14,10 @@ void restore_terminal()
|
|||||||
ioctl(fileno(stdin), TCSETS, &orig);
|
ioctl(fileno(stdin), TCSETS, &orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sigint_handler(int)
|
void signal_handler(int signo)
|
||||||
{
|
{
|
||||||
restore_terminal();
|
restore_terminal();
|
||||||
raise(SIGINT);
|
raise(signo);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* getpass()
|
char* getpass()
|
||||||
@ -41,10 +41,12 @@ char* getpass()
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
sa.sa_handler = sigint_handler;
|
sa.sa_handler = signal_handler;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = SA_RESETHAND;
|
sa.sa_flags = SA_RESETHAND;
|
||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
|
sigaction(SIGTERM, &sa, NULL);
|
||||||
|
sigaction(SIGQUIT, &sa, NULL);
|
||||||
|
|
||||||
atexit(restore_terminal);
|
atexit(restore_terminal);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user