<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>OK, I got the picture, thanks a lot!<div><br></div><div> > What is it that you are trying to do anyway?<br><br>Well, target termination during detach is unexpected, so my customers might get confused. Fortunately I am in control of the target program too, so I'll just ignore SIGHUP for the time being.</div><div><br></div><div>Thanks,</div><div>Eugene<br><br><div>> From: labath@google.com<br>> Date: Thu, 31 Mar 2016 09:16:06 +0100<br>> Subject: Re: [lldb-dev] SBProcess::Detach kills target<br>> To: eugenebi@hotmail.com<br>> CC: lldb-dev@lists.llvm.org<br>> <br>> We are not sending the SIGHUP, it is automatically getting sent by the<br>> OS when the master end of the pty gets closed. The reason you are not<br>> seeing this in the attach scenario is that we do not intercept<br>> inferior stdio in this case (it's not possible, or desirable, since<br>> the process is already running). This is also the reason<br>> SBProcess.GetSTDOUT does not return anything in the attach scenario. I<br>> am not familiar with the details of the Mac implementation and I<br>> cannot tell you why is this not happening there.<br>> I guess one way to fix this would be to have a special mode of<br>> starting the inferior without a controlling terminal, but I am not<br>> sure if this would be a generally useful feature. What is it that you<br>> are trying to do anyway?<br>> <br>> pl<br>> <br>> On 30 March 2016 at 23:03, Eugene Birukov <eugenebi@hotmail.com> wrote:<br>> > Just a wild guess - is this SIGHUP because stdin/stdout are broken? I.e. the<br>> > debugger closes its pty's on detach and that causes the signal?<br>> > What is the behavior on MAC?<br>> ><br>> > ________________________________<br>> > To: labath@google.com<br>> > Date: Wed, 30 Mar 2016 14:49:33 -0700<br>> > CC: lldb-dev@lists.llvm.org<br>> > Subject: Re: [lldb-dev] SBProcess::Detach kills target<br>> > From: lldb-dev@lists.llvm.org<br>> ><br>> ><br>> > Right, my bad. The problem was that when debugger detaches the stdio does<br>> > not go anywhere so I failed to see my printf.<br>> ><br>> > Still, is this how it is supposed to be? I naively assume that if we don't<br>> > send SIGHUP in attach scenario we should not send it in launch scenario too.<br>> ><br>> > Thanks,<br>> > Eugene<br>> ><br>> >> From: labath@google.com<br>> >> Date: Wed, 30 Mar 2016 10:22:33 +0100<br>> >> Subject: Re: [lldb-dev] SBProcess::Detach kills target<br>> >> To: eugenebi@hotmail.com<br>> >> CC: jingham@apple.com; lldb-dev@lists.llvm.org<br>> >><br>> >> So I have made a small test program (which does nothing but spin in a<br>> >> loop), and indeed it is the SIGHUP that kills it after detach. If the<br>> >> test program blocks the signal, then it continues running even after<br>> >> detach:<br>> >> $ cat a.c<br>> >> #include <unistd.h><br>> >> #include <signal.h><br>> >><br>> >> int main() {<br>> >> signal(SIGHUP, SIG_IGN);<br>> >> for (;;) sleep(1);<br>> >> }<br>> >> $ cc a.c -g<br>> >> $ ps -A | grep a.out<br>> >> $ ~/ll/build/dbg/bin/lldb ./a.out<br>> >> (lldb) target create "./a.out"<br>> >> Current executable set to './a.out' (x86_64).<br>> >> (lldb) b 6<br>> >> Breakpoint 1: where = a.out`main + 19 at a.c:6, address =<br>> >> 0x0000000000400590<br>> >> (lldb) r<br>> >> Process 13416 launched: './a.out' (x86_64)<br>> >> Process 13416 stopped<br>> >> * thread #1: tid = 13416, 0x0000000000400590 a.out`main + 19 at a.c:6,<br>> >> name = 'a.out', stop reason = breakpoint 1.1<br>> >> frame #0: 0x0000000000400590 a.out`main + 19 at a.c:6<br>> >> 3<br>> >> 4 int main() {<br>> >> 5 signal(SIGHUP, SIG_IGN);<br>> >> -> 6 for (;;) sleep(1);<br>> >> 7 }<br>> >> (lldb) detach<br>> >> Process 13416 detached<br>> >> (lldb) q<br>> >> $ ps -A | grep a.out<br>> >> 13416 ? 00:00:00 a.out<br>> >><br>> >><br>> >> On 29 March 2016 at 18:38, Eugene Birukov <eugenebi@hotmail.com> wrote:<br>> >> > I believe this is not SIGHUP on debugger exit. I am using my own C++<br>> >> > program<br>> >> > that calls into LLDB API. So, this program is still alive after calling<br>> >> > SBProcess::Detach() but the target dies. Also, the target intercepts<br>> >> > SIGHUP<br>> >> > to do cleanup before exiting. I put printf there, it was not hit.<br>> >> The fact whether your program is alive irrelevant. What matters is<br>> >> that by cleaning up the process structure, we will also close the<br>> >> master end of the pty used for inferior communication, and this is<br>> >> what causes the SIGHUP. For that reason you also cannot use a printf<br>> >> to do diagnostics as the output has nowhere to go. Note that lldb's<br>> >> behavior here will be different from gdb as gdb does not do stdio<br>> >> redirection, and has the inferior share the pty with the debugger (in<br>> >> which case your program will die when you close the terminal window).<br>> >><br>> >> ><br>> >> > I tried interactive LLDB, the target is not there:<br>> >> ><br>> >> > Process 49145 stopped<br>> >> > * thread #1: tid = 49145, ..., stop reason = signal SIGSTOP<br>> >> > frame #0: 0x00007ffff6a5bbed libc.so.6 at syscall-template.S:81<br>> >> > (lldb) detach<br>> >> > Process 49145 detached<br>> >> > (lldb) q<br>> >> > eugene@EUGENEBI-L1:~/tmp$ ps<br>> >> > PID TTY TIME CMD<br>> >> > 30714 pts/17 00:00:00 bash<br>> >> > 49259 pts/17 00:00:00 ps<br>> >> Note that the inferior will not show up here even if it exists, as ps<br>> >> will only list the processes with the same tty, but at this point the<br>> >> inferior process has no tty.<br>> >><br>> >> Good luck with your investigations.<br>> >><br>> >> pl<br>> ><br>> > _______________________________________________ lldb-dev mailing list<br>> > lldb-dev@lists.llvm.org<br>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev<br></div></div> </div></body>
</html>