- /* It's important to write the file *before*
- * the parent ends, because the file may be
- * read as soon as the parent ends.
- */
- if(pidfile) {
- pidfp = fopen(pidfile, "w+");
- if(!pidfp) {
- PERROR("fopen (%s)", pidfile);
- WARN("killing child process");
- result = kill(child_pid, SIGTERM);
- if(result == -1) {
- PERROR("kill");
- }
- return -1;
- }
-
- fprintf(pidfp, "%d\n", child_pid);
- fclose(pidfp);
- }
-