pthread_kill in IOS causes debugger to stop app.

Hi,


I am using pthread_kill in an IOS app to 'suspend' the pthreads for a custom garbage collector.


However, when the app code executes pthread_kill( SIGUSR2 ), the xcode debugger stops the app entirely. I have tried SIGUSR1 too.


Is there any way to prevent this from happening?


I can run the app directly from the device so I know it sort of works, but I can't continue app execution in the debugger, and even if I could it wouldn't be that helpful because GC happens fairly frequently.


Bye,

Mark

Accepted Reply

The debugger will stop on most catchable signals, because they usually indicate a problem that needs debugging. You can control its behavior using the "process handle" command. For example, you can issue the command:


process handle -s0 -n0 -p1 SIGUSR1


to make the debugger not stop, not notify, and pass the SIGUSR1 signal through to the app.


To do this every time, you can create a breakpoint on main(), set the above as a command to run when the breakpoint is hit, and mark the breakpoint so that it automatically continues.

Replies

Solved!


I had to add a breakpoint to main with "process handle -p1 -s0 SIGUSR2".


It all seems to be working well now, although suspending threads seem to be a bit slow (10ms-ish on an ipad mini2) but it's OK for loading stuff in the background etc.


Is there another way to suspend threads? How does c# runtime on ios do it?

The debugger will stop on most catchable signals, because they usually indicate a problem that needs debugging. You can control its behavior using the "process handle" command. For example, you can issue the command:


process handle -s0 -n0 -p1 SIGUSR1


to make the debugger not stop, not notify, and pass the SIGUSR1 signal through to the app.


To do this every time, you can create a breakpoint on main(), set the above as a command to run when the breakpoint is hit, and mark the breakpoint so that it automatically continues.