connection_s *cp = SERVER_CONNECTION( serp ) ;
struct service_config *scp = SVC_CONF( sp ) ;
const char *func = "child_process" ;
+ int fd, null_fd;
signal_default_state();
signals_pending[0] = -1;
signals_pending[1] = -1;
- Sclose(0);
- Sclose(1);
- Sclose(2);
+ if ( ( null_fd = open( "/dev/null", O_RDONLY ) ) == -1 )
+ {
+ msg( LOG_ERR, func, "open('/dev/null') failed: %m") ;
+ _exit( 1 ) ;
+ }
+
+ for ( fd = 0 ; fd <= MAX_PASS_FD ; fd++ )
+ {
+ if ( fd != null_fd && dup2( null_fd, fd ) == -1 )
+ {
+ msg( LOG_ERR, func, "dup2(%d, %d) failed: %m") ;
+ _exit( 1 ) ;
+ }
+ }
+ if ( null_fd > MAX_PASS_FD )
+ (void) Sclose( null_fd ) ;
#ifdef DEBUG_SERVER
return FAILED;
if ( last == NULL ) {
- last = SAIN( calloc( 1, sizeof(union xsockaddr) ) );
- SVC_LAST_DGRAM_ADDR(sp) = (union xsockaddr *)last;
+ SVC_LAST_DGRAM_ADDR(sp) = SAIN( calloc( 1, sizeof(union xsockaddr) ) );
+ last = SAIN( SVC_LAST_DGRAM_ADDR(sp) );
}
(void) time( ¤t_time ) ;
return FAILED;
if( last == NULL ) {
- last = SAIN6(calloc( 1, sizeof(union xsockaddr) ) );
- SVC_LAST_DGRAM_ADDR( sp ) = (union xsockaddr *)last;
+ SVC_LAST_DGRAM_ADDR(sp) = SAIN6(calloc( 1, sizeof(union xsockaddr) ) );
+ last = SAIN6(SVC_LAST_DGRAM_ADDR(sp));
}
(void) time( ¤t_time ) ;