Ok great, I'm attaching a patch here that just uses getpgid() to determine
the pgid to use with waitpid(). I get the same unit test results before and
after the patch (there are a few tests that fail consistently for me). I
tried using a simple -1 with waitpid() but this results in a hang in the
unit tests. This is probably something worth investigating but for now this
patch does resolve the issues around waitpid() when attaching.
I mentioned a few issues I ran into with the unit tests in the email I just
pinged with a Linux detach patch, basically there appears to be a bug or
limitation somewhere in that doing a "continue" in asynchronous mode in a
unit test breaks things and this is needed for most attach-related debug
testing. I can probably look into this (along with the couple of failing
tests I have) but likely won't be able to this week. I haven't filed a bug
for the consistently-failing tests on my end since it doesn't appear to be
happening for others and I haven't had a chance to investigate here, let me
know if I should file a bug anyway.
On Tue, Mar 25, 2014 at 6:30 PM, Todd Fiala <[email protected]> wrote:
> I'd suggest trying the change, running the tests, and see if anything new
> fails.
>
> And if this fixes currently broken behavior, add a test to make sure we
> don't regress it. I'm pretty sure if it breaks something we'll know pretty
> quickly (either via bugs or our own usage). At which point - we should add
> a test so we don't regress in the future and perhaps add a few comments as
> to the reason.
>
>
> On Tue, Mar 25, 2014 at 9:54 AM, <[email protected]> wrote:
>
>> Why are you waiting for process groups? That's not something we have to
>> do on Mac OS X.
>>
>> Jim
>>
>>
>> On Mar 25, 2014, at 1:17 AM, Andrew MacPherson <[email protected]>
>> wrote:
>>
>> > Currently under Linux if you attach to a process whose process group id
>> is not equal to its process id (such as the child process of a fork() call)
>> the calls to waitpid() that pass -1*pid will return ECHILD since the pid
>> argument refers to a process group that doesn't exist. These calls occur in
>> Host::MonitorChildProcessThreadFunction() and the Linux ProcessMonitor.
>> >
>> > Changing -1*pid to simply -1 or to -1*getpgid(pid) resolves the issue
>> but it's not clear if this is the right fix as I'm unsure how other OSes
>> deal with this scenario.
>> >
>> > Any thoughts?
>> >
>> > Thanks,
>> > Andrew
>> > _______________________________________________
>> > lldb-dev mailing list
>> > [email protected]
>> > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>>
>> _______________________________________________
>> lldb-dev mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>>
>
>
>
> --
> Todd Fiala | Software Engineer | [email protected] | 650-943-3180
>
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index e5a0f33..ab78c12 100644
--- a/source/Host/common/Host.cpp
+++ b/source/Host/common/Host.cpp
@@ -169,7 +169,7 @@ MonitorChildProcessThreadFunction (void *arg)
const bool monitor_signals = info->monitor_signals;
assert (info->pid <= UINT32_MAX);
- const ::pid_t pid = monitor_signals ? -1 * info->pid : info->pid;
+ const ::pid_t pid = monitor_signals ? -1 * getpgid(info->pid) : info->pid;
delete info;
diff --git a/source/Plugins/Process/Linux/ProcessMonitor.cpp b/source/Plugins/Process/Linux/ProcessMonitor.cpp
index 3dec6de..a9c428d 100644
--- a/source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ b/source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -1767,7 +1767,7 @@ ProcessMonitor::StopThread(lldb::tid_t tid)
int status = -1;
if (log)
log->Printf ("ProcessMonitor::%s(bp) waitpid...", __FUNCTION__);
- lldb::pid_t wait_pid = ::waitpid (-1*m_pid, &status, __WALL);
+ lldb::pid_t wait_pid = ::waitpid (-1*getpgid(m_pid), &status, __WALL);
if (log)
log->Printf ("ProcessMonitor::%s(bp) waitpid, pid = %" PRIu64 ", status = %d", __FUNCTION__, wait_pid, status);
_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev