Make sure we restore the process events so they aren't hijacked when using the async attach when attaching to a process by name and with waitfor.

<rdar://problem/22821480>

llvm-svn: 250768
This commit is contained in:
Greg Clayton 2015-10-20 00:14:20 +00:00
parent b3f0c3400f
commit e75e5d8afa
1 changed files with 18 additions and 11 deletions

View File

@ -3162,19 +3162,26 @@ Target::Attach (ProcessAttachInfo &attach_info, Stream *stream)
error = process_sp->Attach (attach_info);
}
if (error.Success () && process_sp && async == false)
if (error.Success () && process_sp)
{
state = process_sp->WaitForProcessToStop (nullptr, nullptr, false, attach_info.GetHijackListener ().get (), stream);
process_sp->RestoreProcessEvents ();
if (state != eStateStopped)
if (async)
{
const char *exit_desc = process_sp->GetExitDescription ();
if (exit_desc)
error.SetErrorStringWithFormat ("%s", exit_desc);
else
error.SetErrorString ("process did not stop (no such process or permission problem?)");
process_sp->Destroy (false);
process_sp->RestoreProcessEvents ();
}
else
{
state = process_sp->WaitForProcessToStop (nullptr, nullptr, false, attach_info.GetHijackListener ().get (), stream);
process_sp->RestoreProcessEvents ();
if (state != eStateStopped)
{
const char *exit_desc = process_sp->GetExitDescription ();
if (exit_desc)
error.SetErrorStringWithFormat ("%s", exit_desc);
else
error.SetErrorString ("process did not stop (no such process or permission problem?)");
process_sp->Destroy (false);
}
}
}
return error;