unlocking signal mutex before writing output added