X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslapcat.c;h=a87c8eb32543b8c583623f6550668a7146934f40;hb=4a107089d82ecdaca788fc6ecdef34d3d4fc19df;hp=e8a4beda5aab7166306059eb2108c1c0a5ad0925;hpb=495c3156725ab4a1fcbeb55fc8e48c2c96d555b5;p=openldap diff --git a/servers/slapd/slapcat.c b/servers/slapd/slapcat.c index e8a4beda5a..a87c8eb325 100644 --- a/servers/slapd/slapcat.c +++ b/servers/slapd/slapcat.c @@ -30,6 +30,15 @@ #include #include "slapcommon.h" +#include "ldif.h" + +static int gotsig; + +static RETSIGTYPE +slapcat_sig( int sig ) +{ + gotsig=1; +} int slapcat( int argc, char **argv ) @@ -41,6 +50,15 @@ slapcat( int argc, char **argv ) slap_tool_init( progname, SLAPCAT, argc, argv ); +#ifdef SIGPIPE + (void) SIGNAL( SIGPIPE, slapcat_sig ); +#endif +#ifdef SIGHUP + (void) SIGNAL( SIGHUP, slapcat_sig ); +#endif + (void) SIGNAL( SIGINT, slapcat_sig ); + (void) SIGNAL( SIGTERM, slapcat_sig ); + if( !be->be_entry_open || !be->be_entry_close || !be->be_entry_first || @@ -58,15 +76,19 @@ slapcat( int argc, char **argv ) exit( EXIT_FAILURE ); } + op.o_bd = be; for ( id = be->be_entry_first( be ); id != NOID; id = be->be_entry_next( be ) ) { char *data; int len; - Entry* e = be->be_entry_get( be, id ); - op.o_bd = be; + Entry* e; + + if ( gotsig ) + break; + e = be->be_entry_get( be, id ); if ( e == NULL ) { printf("# no data for entry id=%08lx\n\n", (long) id ); rc = EXIT_FAILURE; @@ -101,8 +123,8 @@ slapcat( int argc, char **argv ) break; } - fputs( data, ldiffp ); - fputs( "\n", ldiffp ); + fputs( data, ldiffp->fp ); + fputs( "\n", ldiffp->fp ); } be->be_entry_close( be );