- if (pidfile) {
- f = fopen(pidfile, "w");
- if (!f) {
- syslog(LOG_CRIT, "unable to write pidfile %s", pidfile);
- }
- fprintf(f, "%d\n", getpid());
- fflush(f);
+ if (argc - optind != 1) {
+ usage();
+ return EXIT_FAILURE;
+ }
+
+ if (pidfile_open(pidfile) < 0) {
+ syslog(LOG_CRIT, "unable to write pidfile %s", pidfile);
+ return EXIT_FAILURE;