rem: Ns_Log(Error, "exec %s: dup(%d) failed: %s",
add: Ns_Log(Error, "exec %s: dup failed: %s",
context: ExecProc(char *exec, char *dir, int fdin, int fdout, char **argv,    	 char **envp){    struct iovec iov[2];    int    pid, nread, errpipe[2], errnum, result;    /*     * Create a pipe for child error message.     */         if (ns_pipe(errpipe) < 0) {        Ns_Log(Error, "exec: ns_pipe() failed: %s", strerror(errno));	return -1;    }    /*     * Fork child and read error message (if any).     */    pid = ns_fork();    if (pid < 0) {        close(errpipe[0]);        close(errpipe[1]);        Ns_Log(Error, "exec: ns_fork() failed: %s", strerror(errno));	return -1;    }    iov[0].iov_base = (caddr_t) &result;    iov[1].iov_base = (caddr_t) &errnum;    iov[0].iov_len = iov[1].iov_len = sizeof(int);    if (pid == 0) {	/*	 * Setup child and exec the program, writing any error back	 * to the parent if necessary.	 */        close(errpipe[0]);        if (dir != NULL && chdir(dir) != 0) {	    result = ERR_CHDIR;        } else if ((fdin == 1 && (fdin = dup(1)) < 0) ||    	    	    (fdout == 0 && (fdout = dup(0)) < 0) ||	    	    (fdin != 0 && dup2(fdin, 0) < 0) ||    	    	    (fdout != 1 && dup2(fdout, 1) < 0)) {	    result = ERR_DUP;	} else {	    if (fdin > 2) {		close(fdin);	    }	    if (fdout > 2) {            	close(fdout);	    }            NsRestoreSignals();	    Ns_NoCloseOnExec(0);	    Ns_NoCloseOnExec(1);	    Ns_NoCloseOnExec(2);            execve(exec, argv, envp);	    /* NB: Not reached on successful execve(). */	    result = ERR_EXEC;	}	errnum = errno;	(void) writev(errpipe[1], iov, 2);	_exit(1);	    } else {    	/*	 * Read result and errno from the child if any.	 */        close(errpipe[1]);	do {            nread = readv(errpipe[0], iov, 2);	} while (nread < 0 && errno == EINTR);        close(errpipe[0]);        if (nread == 0) {	    errnum = 0;	    result = pid;	} else {            if (nread != (sizeof(int) * 2)) {	    	Ns_Log(Error, "exec: %s: error reading status from child: %s",			   exec, strerror(errno));            } else {		switch (result) {		    case ERR_CHDIR:            		Ns_Log(Error, "exec %s: chdir(%s) failed: %s",				exec, dir, strerror(errnum));	    		break;		    case ERR_DUP:	    		Ns_Log(Error, "exec %s: dup(%d) failed: %s",				exec, strerror(errnum));	    		break;		    case ERR_EXEC:	    		Ns_Log(Error, "exec %s: execve() failed: %s",				exec, strerror(errnum));	    		break;		    default:	    		Ns_Log(Error, "exec %s: unknown result from child: %d",				exec, result);	    		break;		}	    }            (void) waitpid(pid, NULL, 0);	    errno = errnum;        }    }    return result;}