Adding safeguard to childProcess.exec and spawn