diff --git a/tools/ompipe.c b/tools/ompipe.c
index 0b145b559e..a3c460ff54 100644
--- a/tools/ompipe.c
+++ b/tools/ompipe.c
@@ -412,10 +412,12 @@ ENDparseSelectorAct
BEGINdoHUP
CODESTARTdoHUP
+ pthread_mutex_lock(&pData->mutWrite);
if(pData->fd != -1) {
close(pData->fd);
pData->fd = -1;
}
+ pthread_mutex_unlock(&pData->mutWrite);
ENDdoHUP