2006-06-08 22:27:17 +04:00
|
|
|
/* -*- C -*-
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*
|
|
|
|
* A test to trap user signals
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte_config.h"
|
2006-06-08 22:27:17 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
#include "orte/runtime/orte_globals.h"
|
2006-06-08 22:27:17 +04:00
|
|
|
#include "orte/runtime/runtime.h"
|
|
|
|
|
|
|
|
void sigusr_handler(int signum)
|
|
|
|
{
|
|
|
|
switch (signum) {
|
|
|
|
case SIGUSR1:
|
2009-03-06 00:14:18 +03:00
|
|
|
fprintf(stderr, "%s Trapped SIGUSR1\n", orte_util_print_name_args(ORTE_PROC_MY_NAME));
|
2006-06-08 22:27:17 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SIGUSR2:
|
2009-03-06 00:14:18 +03:00
|
|
|
fprintf(stderr, "%s Trapped SIGUSR2\n", orte_util_print_name_args(ORTE_PROC_MY_NAME));
|
2006-06-08 22:27:17 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
2009-03-06 00:14:18 +03:00
|
|
|
fprintf(stderr, "%s Undefined signal %d trapped\n", orte_util_print_name_args(ORTE_PROC_MY_NAME), signum);
|
2006-06-08 22:27:17 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void exit_handler(int signum)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
int i;
|
|
|
|
double pi;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
orte_init(ORTE_TOOL_WITH_NAME);
|
|
|
|
|
2006-06-08 22:27:17 +04:00
|
|
|
if (signal(SIGUSR1, sigusr_handler) == SIG_IGN) {
|
|
|
|
fprintf(stderr, "Could not setup signal trap for SIGUSR1\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signal(SIGUSR2, sigusr_handler) == SIG_IGN) {
|
|
|
|
fprintf(stderr, "Could not setup signal trap for SIGUSR2\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signal(SIGINT, exit_handler) == SIG_IGN) {
|
|
|
|
fprintf(stderr, "Could not setup signal trap for SIGINT\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signal(SIGHUP, exit_handler) == SIG_IGN) {
|
|
|
|
fprintf(stderr, "Could not setup signal trap for SIGHUP\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (signal(SIGTERM, exit_handler) == SIG_IGN) {
|
|
|
|
fprintf(stderr, "Could not setup signal trap for SIGTERM\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (1) {
|
|
|
|
i++;
|
|
|
|
pi = i / 3.14159256;
|
|
|
|
if (i > 100) i = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|