+ filep_pidfile = fopen(pidfile, "w");
+ if (filep_pidfile == NULL) {
+ VLOG_FATAL("failed to open %s (%s)", pidfile, ovs_strerror(errno));
+ }
+
+ fatal_signal_add_hook(unlink_pidfile, NULL, NULL, true);
+
+ fprintf(filep_pidfile, "%d\n", _getpid());
+ if (fflush(filep_pidfile) == EOF) {
+ VLOG_FATAL("Failed to write into the pidfile %s", pidfile);
+ }
+
+ /* Don't close the pidfile till the process exits. */