Let's lock our write operation into the pipe with a mutex

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>