write the main pid into pid file