[Driver] Fix a segfault in signal handlers

Summary:
If we recieve a SIGCONT or SIGTSTP, while the driver is shutting down (which, sometimes, we do,
for reasons which are not completely clear to me), we would crash to due a null pointer
dereference. Guard against this situation.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D18965

llvm-svn: 265958
This commit is contained in:
Pavel Labath 2016-04-11 16:40:09 +00:00
parent c98de13871
commit bb5c39d79e
1 changed files with 6 additions and 2 deletions

View File

@ -1283,7 +1283,9 @@ sigint_handler (int signo)
void
sigtstp_handler (int signo)
{
g_driver->GetDebugger().SaveInputTerminalState();
if (g_driver)
g_driver->GetDebugger().SaveInputTerminalState();
signal (signo, SIG_DFL);
kill (getpid(), signo);
signal (signo, sigtstp_handler);
@ -1292,7 +1294,9 @@ sigtstp_handler (int signo)
void
sigcont_handler (int signo)
{
g_driver->GetDebugger().RestoreInputTerminalState();
if (g_driver)
g_driver->GetDebugger().RestoreInputTerminalState();
signal (signo, SIG_DFL);
kill (getpid(), signo);
signal (signo, sigcont_handler);