<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - lldb not sending SIGINT to inferior process"
   href="https://llvm.org/bugs/show_bug.cgi?id=28989">28989</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lldb not sending SIGINT to inferior process
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>penryu@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16958" name="attach_16958" title="Source file main.c used to reproduce issue">attachment 16958</a> <a href="attachment.cgi?id=16958&action=edit" title="Source file main.c used to reproduce issue">[details]</a></span>
Source file main.c used to reproduce issue

When lldb connects to a previously launchd process via pid, issuing ^C (Ctrl-C)
in the tty of the inferior process correctly sends SIGINT to the inferior
process. At this point, commands to `process handle SIGINT ...` can be used to
route the signal as the user wants.

However, if the inferior process is launched by lldb itself, either via `lldb
./some_bin` at the command line, or via `target create ...` from within lldb;
Ctrl-C is only received by lldb, and cannot be forwarded to the inferior
process as a SIGINT.

Note that sending a SIGINT to the debugged process with kill(1) or kill(2) will
work, but is only a workaround.

= Produce executable from attached source =

$ clang -g -o main main.c

= Attach to pid =

# launch ./main in separate tty

(lldb) pr at -p NNNNN
(lldb) pr ha SIGINT -p true -s false
(lldb) c

# issue ^C in tty running ./main
# ./main process exits via custom handler as intended

= Launch from inside lldb =

$ lldb
(lldb) ta cr ./main
(lldb) br s -n main
(lldb) r
Process NNNNN stopped ... stop reason = signal SIGSTOP
[...]
(lldb) pr ha SIGINT -p true -s false
(lldb) c
^C
Process NNNNN stopped ... stop reason = signal SIGSTOP
[...]

# ^C never results in a SIGINT to inferior process</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>