(1) Manually. Complete the following in a shell. Continue to press Ctrl + C on the command line.
gdb -x print_callstack.gdb -p pid
or, (2) send signals to pid several times at the same time on another shell, as in the lower loop
let count=0; \
while [ $count -le 100 ]; do \
kill -INT pid ; sleep 0.10; \
let $count=$count+1; \
done
print_callstack.gdb (1) :
set pagination 0
set $count = 0
while $count < 100
backtrace
continue
set $count = $count + 1
end
detach
quit