add option to write pid in an external file