forked from OSchip/llvm-project
Delay sync with the parent thread in ProcessLinux/ProcessMonitor.
This patch removes a potential race condition between a process monitor thread and its parent waiting to interrogate the success/failure of the launch. llvm-svn: 123803
This commit is contained in:
parent
d2d6665c71
commit
570243b5d9
|
@ -607,7 +607,7 @@ ProcessMonitor::OperationThread(void *arg)
|
||||||
if (!Launch(args))
|
if (!Launch(args))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ServeOperation(args->m_monitor);
|
ServeOperation(args);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,8 +716,6 @@ ProcessMonitor::Launch(LaunchArgs *args)
|
||||||
process.SendMessage(ProcessMessage::Trace(pid));
|
process.SendMessage(ProcessMessage::Trace(pid));
|
||||||
|
|
||||||
FINISH:
|
FINISH:
|
||||||
// Sync with our parent thread now that the launch operation is complete.
|
|
||||||
sem_post(&args->m_semaphore);
|
|
||||||
return args->m_error.Success();
|
return args->m_error.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,15 +817,20 @@ ProcessMonitor::MonitorSIGTRAP(ProcessMonitor *monitor, lldb::pid_t pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ProcessMonitor::ServeOperation(ProcessMonitor *monitor)
|
ProcessMonitor::ServeOperation(LaunchArgs *args)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
pollfd fdset;
|
pollfd fdset;
|
||||||
|
ProcessMonitor *monitor = args->m_monitor;
|
||||||
|
|
||||||
fdset.fd = monitor->m_server_fd;
|
fdset.fd = monitor->m_server_fd;
|
||||||
fdset.events = POLLIN | POLLPRI;
|
fdset.events = POLLIN | POLLPRI;
|
||||||
fdset.revents = 0;
|
fdset.revents = 0;
|
||||||
|
|
||||||
|
// We are finised with the arguments and are ready to go. Sync with the
|
||||||
|
// parent thread and start serving operations on the inferior.
|
||||||
|
sem_post(&args->m_semaphore);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if ((status = poll(&fdset, 1, -1)) < 0)
|
if ((status = poll(&fdset, 1, -1)) < 0)
|
||||||
|
|
|
@ -197,7 +197,7 @@ private:
|
||||||
EnableIPC();
|
EnableIPC();
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ServeOperation(ProcessMonitor *monitor);
|
ServeOperation(LaunchArgs *args);
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
DupDescriptor(const char *path, int fd, int flags);
|
DupDescriptor(const char *path, int fd, int flags);
|
||||||
|
|
Loading…
Reference in New Issue