FreeBSD/usr.sbin/ctm/ctm_dequeue/ctm_dequeue.c
/*
 * Run sendmail with the given file descriptor as standard input.
 * Sendmail will decode the destination from the message contents.
 * Returns 0 on success, 1 on failure.
 */
Run sendmail with the given file descriptor as standard input.
Sendmail will decode the destination from the message contents.
Returns 0 on success, 1 on failure.
Run sendmail with the given file descriptor as standard input . Sendmail will decode the destination from the message contents . Returns 0 on success 1 on failure .
int
run_sendmail(int ifd)
{
    pid_t child, pid;
    int status;
    switch (child = fork())
    {
    case -1:
	err("*fork");
	return(1);
    case 0:	
	dup2(ifd, 0);
	execl(_PATH_SENDMAIL, _PATH_SENDMAIL, "-odq", "-t", (char *)NULL);
	err("*exec: %s", _PATH_SENDMAIL);
	_exit(1);
    default:	
	while ((pid = wait(&status)) != child)
	{
	    if (pid == -1 && errno != EINTR)
	    {
		err("*wait");
		return(1);
	    }
	}
	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
	{
	    err("sendmail failed");
	    return(1);
	}
    }
    return(0);
}
int run_sendmail ( int ifd ) { pid_t child , pid ; int status ; switch ( child = fork ( ) ) { case -1 : err ( " " ) ; return ( 1 ) ; case 0 : dup2 ( ifd , 0 ) ; execl ( _PATH_SENDMAIL , _PATH_SENDMAIL , " " , " " , ( char * ) NULL ) ; err ( " " , _PATH_SENDMAIL ) ; _exit ( 1 ) ; default : while ( ( pid = wait ( & status ) ) != child ) { if ( pid == -1 && errno != EINTR ) { err ( " " ) ; return ( 1 ) ; } } if ( ! WIFEXITED ( status ) || WEXITSTATUS ( status ) != 0 ) { err ( " " ) ; return ( 1 ) ; } } return ( 0 ) ; }
Run sendmail with the given file descriptor as standard input.
Run sendmail with the given file descriptor as standard input .
/* Child */ /* Parent */