/****************************************************************
 *                                                              *
 *  LIBDIST v1.0						*
 *                                                              *
 *  sig-test.c - test signals                                   *
 *                                                              *
 *  Last changed: 19.02.96                                      *
 *  Author: Frank Kargl (frank.kargl@informatik.uni-ulm.de)     *
 *                                                              *
 *  Restrictions: works only for Solaris 2.6 or above           *
 *                                                              *
 ****************************************************************/

#include "libdist.h"
#include "config.h"

/* you can send signals to this little programm using the kill command */
/* and see it react for a certain amount of time */

/* what signals to use */
#define SIGNAL1 SIGUSR1
#define SIGNAL2 SIGUSR2

/* just give a echo */
void echo(int what) {
	printf("\nECHO %d\n",what);
	return;
}

int main() {
	int i;

	/* catch signals */
	dl_sig_catch(SIGNAL1,echo);
	dl_sig_catch(SIGNAL2,echo);

	/* now do some output so you see the difference when signals arrive */
	for(i=0;i<20;i++) {
		printf("TEST\n");
		sleep(1);
	}

	/* free signals again */
	dl_sig_free(SIGNAL1);
	dl_sig_free(SIGNAL2);

	/* now sending signals will stop the process */

	/* now more output */
	for(i=0;i<10;i++) {
		printf("HUGO\n");
		sleep(1);
	}
	
	return 0;
}
