fix EINTR drop on child pipe read, publish active after memoryMap is populated
This commit is contained in:
parent
44126f7709
commit
717650d514
|
|
@ -165,9 +165,9 @@ protected:
|
|||
void cbCreateProcessEvent(const pid_t pid, const ElfBug::ptr ep) override
|
||||
{
|
||||
activePid.store(pid, std::memory_order_release);
|
||||
active.store(true, std::memory_order_release);
|
||||
entryPoint = ep;
|
||||
refreshMemoryMap();
|
||||
active.store(true, std::memory_order_release);
|
||||
if(cb.onCreateProcess)
|
||||
cb.onCreateProcess(pid, ep, cb.userdata);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ namespace ElfBug
|
|||
if(mStepPending.load(std::memory_order_acquire) && mThread)
|
||||
{
|
||||
mStepPending.store(false, std::memory_order_release);
|
||||
// TODO: mPendingSignal is dropped here, decide the policy
|
||||
mThread->StepInto();
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <sys/personality.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <cerrno>
|
||||
#include <csignal>
|
||||
#include <cstring>
|
||||
|
||||
|
|
@ -114,9 +115,21 @@ namespace ElfBug
|
|||
close(pipeFds[1]);
|
||||
|
||||
char errBuf[256] = {};
|
||||
const ssize_t n = read(pipeFds[0], errBuf, sizeof(errBuf) - 1);
|
||||
ssize_t n;
|
||||
do
|
||||
{
|
||||
n = read(pipeFds[0], errBuf, sizeof(errBuf) - 1);
|
||||
} while(n == -1 && errno == EINTR);
|
||||
close(pipeFds[0]);
|
||||
|
||||
if(n == -1)
|
||||
{
|
||||
const std::string err = strerror(errno);
|
||||
waitpid(pid, nullptr, 0);
|
||||
cbInternalError("read() from child pipe failed: " + err);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(n > 0)
|
||||
{
|
||||
waitpid(pid, nullptr, 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue