add global locks for IO to stdout and stderr