added global mutex to not interfere with other rg processes
Signed-off-by: duketwo <duketwoqq@gmail.com>