-/*
- * Clean up existing child.
- * Return 1 if cleaned up fine (or none was started) and 0 otherwise.
- */
-static int
-jobwait(pid_t pid)
-{
- int st;
-
- if (-1 == pid)
- return(1);
-
- if (-1 == waitpid(pid, &st, 0)) {
- perror(NULL);
- exit(EXIT_FAILURE);
- }
-
- return(WIFEXITED(st) && 0 == WEXITSTATUS(st));
-}
-
-/*
- * Start a job (child process), first making sure that the prior one has
- * finished.
- * Return 1 if the prior child exited and the new one started, else 0.
- */
-static int
-jobstart(const char *dst, const char *src, pid_t *pid)
-{
- int fd;
-
- if ( ! jobwait(*pid))
- return(0);
-
- if (-1 == (*pid = fork())) {
- perror(NULL);
- exit(EXIT_FAILURE);
- } else if (*pid > 0)
- return(1);
-
- if (-1 == (fd = open(dst, O_WRONLY|O_TRUNC|O_CREAT, 0644))) {
- perror(dst);
- exit(EXIT_FAILURE);
- }
-
- if (-1 == dup2(fd, STDOUT_FILENO)) {
- perror(NULL);
- exit(EXIT_FAILURE);
- }
-
- execlp("mandoc", "mandoc", "-T", "html",
- "-O", "fragment",
- "-O", "man=man.cgi?expr=%N&sec=%S",
- src, (char *)NULL);
-
- perror("mandoc");
- exit(EXIT_FAILURE);
- /* NOTREACHED */
-}
-