]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapcat.c
ITS#3818 fix index_substr_any_step keyword
[openldap] / servers / slapd / slapcat.c
index 3e4d7ae12b0f0c61ddebfce96a1ce5ee51ccbb81..a87c8eb32543b8c583623f6550668a7146934f40 100644 (file)
 #include "slapcommon.h"
 #include "ldif.h"
 
+static int gotsig;
+
+static RETSIGTYPE
+slapcat_sig( int sig )
+{
+       gotsig=1;
+}
+
 int
 slapcat( int argc, char **argv )
 {
@@ -42,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 ||
@@ -59,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;