From: Despair MUD <despair@seeker.hermesnet.net>


On Sat, 3 Jan 1998, Doug Brewer wrote:

> 
> Earlier this week I said that I had started using Wreckie boys identd code
> to eliminate my lag on connect problem I was having with the mud.
> Everything worked just fine on the test mud I was using but when I put it
> into use on the regular mud I started having problems.
> 
> After a few hours of operation I would start to get the following:
> 
> Create_ident: pipe: : Too many open files
> 


Been there, done that :) ..There is just one little addition that you have
to make; however, instead of trying to explain where that is I'll just
post the complete function the way it SHOULD be..this will fix your
problems:  (note: take the execl() line from your code )



void create_ident( DESCRIPTOR_DATA *d, long ip, sh_int port )
{
    int fds[2];
    pid_t pid;
     
    /* create pipe first */
    if ( pipe( fds )!=0 )
    {
        perror( "Create_ident: pipe: " );
        return;
    }   
    
    if ( dup2( fds[1], STDOUT_FILENO )!=STDOUT_FILENO )
    {
        perror( "Create_ident: dup2(stdout): " );
        return;
    }
    
    close(fds[1]);
    
    if ( (pid=fork( ))>0 )
    {
        /* parent process */
        d->ifd=fds[0];
        d->ipid=pid;
   }
    else if ( pid==0 )
    {
        /* child process */
        char str_ip[64], str_local[64], str_remote[64];
    
        d->ifd=fds[0];
        d->ipid=pid;
        
        sprintf( str_local, "%d", mudport );
        sprintf( str_remote, "%d", port );
        sprintf( str_ip, "%ld", ip );
         /* take the following line from your code...*/
	 execl( "resolve", "resolve", str_local, str_ip, str_remote, 0 );
        /* Still here --> hmm. An error. */
        log_string( "Exec failed; Closing child." );
        d->ifd=-1;
        d->ipid=-1;
        exit( 0 );
    }
    else
    {
        /* error */
        perror( "Create_ident: fork" );
        close( fds[0] );
    }
 }