add flag for writing pid to a file

Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>