Sending signals in LLDB

Look at the process signal and process handle commands. e.g. with a program like

#include <signal.h>
#include <stdio.h>
#include <unistd.h>

void handler (int in)
{
    puts ("signal handled");
}

int main()
{
    signal (SIGUSR1, handler);
    while (1) 
        sleep (1);
}

if I attach to this with an lldb in another window (so I can type commands to lldb while the process is running -- if I run this program under lldb, the input/output when the program is running will go to the program, not lldb), I can tell lldb to not stop process execution when I send a SIGUSR1 signal (its default is to stop execution so you need to continue it again) and I can send the signal. e.g.

(lldb) pro handle -s false SIGUSR1
NAME        PASS   STOP   NOTIFY
==========  =====  =====  ======
SIGUSR1     true   false  true 
(lldb) pro signal SIGUSR1
Process 6628 stopped and restarted: thread 1 received signal: SIGUSR1

and I'll see signal handled output in the other window, showing that my signal handler was called.

Tags:

Signals

Lldb