Пример #1
0
int main(void) {
    if(signal3(SIGINT,sig_int)==SIG_ERR) {
        printf("sig err");
    }
    sleep(10);
    return(0);
}
Пример #2
0
int test_three()
{
	int retvalue;
	mode = 1;
	count = 0;
	if ((retvalue = signal1("reply", 1)) != 0) {
		printf("Test 3,0 failed return value %d\n", retvalue);
		return 1;
	}
	if ((retvalue = signal2("reply", 1, 2)) != 0) {
		printf("Test 3,1 failed return value %d\n", retvalue);
		return 1;
	}
	if ((retvalue = signal3("reply", 1, 2, 3)) != 0) {
		printf("Test 3,2 failed return value %d\n", retvalue);
		return 1;
	}
	if ((retvalue = data("reply", data_str, SIZEOF_DATA + 1)) != 0) {
		printf("Test 3,3 failed return value %d\n", retvalue);
		return 1;
	}
	sleep(1);
	if (count == 4) {
		printf("Test 3 OK\n");
		return 0;
	} else {
		printf("Test 3 failed %d\n", count);
		return 1;
	}
}
Пример #3
0
static void sig_tstp(int signo){
  printf("\nin sig_tstp\n");
  
  sigset_t mask;
  
  //停止前的操作
  sigemptyset(&mask);
  sigaddset(&mask,SIGTSTP);
  sigprocmask(SIG_UNBLOCK,&mask,NULL);
  
  signal3(SIGTSTP,SIG_DFL);
  kill(getpid(),SIGTSTP);

  printf("mid sig_tstp\n");
  signal3(SIGTSTP,sig_tstp);
  printf("sig_tstp end\n");
  //停止后操作
}
Пример #4
0
int main(void){
  
  int n;
  char buf[BUFFSIZE];
  
  //only catch SIGTSTP with job_control shell
  if(signal3(SIGTSTP,SIG_IGN)==SIG_DFL)
  {
    printf("sig\n");
    signal3(SIGTSTP,sig_tstp);
  }
  
  while((n=read(STDIN_FILENO,buf,BUFFSIZE))>0)
    if(write(STDOUT_FILENO,buf,n)!=n)
      err_sys("write err");

  if(n<0)
    err_sys("read err");

  printf("\nexit\n");
  exit(0);
}
Пример #5
0
void QObjectBenchmark::signal_slot_benchmark()
{
    QFETCH(int, type);

    Object singleObject;
    Object multiObject;
    Functor functor;
    singleObject.setObjectName("single");
    multiObject.setObjectName("multi");

    if (type == 5) {
        QObject::connect(&singleObject, &Object::signal0, functor);
    } else if (type == 4) {
        QObject::connect(&singleObject, &Object::signal0, &singleObject, &Object::slot0);
    } else {
        singleObject.connect(&singleObject, SIGNAL(signal0()), SLOT(slot0()));
    }

    multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(slot0()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal1()));
    multiObject.connect(&multiObject, SIGNAL(signal1()), SLOT(slot1()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal2()));
    multiObject.connect(&multiObject, SIGNAL(signal2()), SLOT(slot2()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal3()));
    multiObject.connect(&multiObject, SIGNAL(signal3()), SLOT(slot3()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal4()));
    multiObject.connect(&multiObject, SIGNAL(signal4()), SLOT(slot4()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal5()));
    multiObject.connect(&multiObject, SIGNAL(signal5()), SLOT(slot5()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal6()));
    multiObject.connect(&multiObject, SIGNAL(signal6()), SLOT(slot6()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal7()));
    multiObject.connect(&multiObject, SIGNAL(signal7()), SLOT(slot7()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal8()));
    multiObject.connect(&multiObject, SIGNAL(signal8()), SLOT(slot8()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal9()));
    multiObject.connect(&multiObject, SIGNAL(signal9()), SLOT(slot9()));

    if (type == 0) {
        QBENCHMARK {
            singleObject.slot0();
        }
    } else if (type == 1) {
Пример #6
0
int test_five(int amount)
{
	int retvalue, i;
	mode = 3;
	count = 0;

	for (i = 0; i < amount; i++) {
		if ((retvalue = signal1("reply", 3)) != 0) {
			printf("Test 5,0 failed return value %d\n", retvalue);
			return 1;
		}
	}
	sleep(1);		/* give time for reply to empty the queue */
	for (i = 0; i < amount; i++) {
		if ((retvalue = signal2("reply", 3, 4)) != 0) {
			printf("Test 5,1 failed return value %d\n", retvalue);
			return 1;
		}
	}
	sleep(1);		/* give time for reply to empty the queue */
	for (i = 0; i < amount; i++) {
		if ((retvalue = signal3("reply", 3, 4, 65534)) != 0) {
			printf("Test 5,2 failed return value %d\n", retvalue);
			return 1;
		}
	}
	sleep(1);		/* give time for reply to empty the queue */
	for (i = 0; i < amount; i++) {
		if ((retvalue = data("reply", data_str, SIZEOF_DATA + 1)) != 0) {
			printf("Test 5,3 failed return value %d\n", retvalue);
			return 1;
		}
	}
	sleep(1);		/* give time for reply to empty the queue */
	if (count == (4 * amount)) {
		printf("Test 5 OK\n");
		return 0;
	} else {
		printf("Test 5 failed, received %d out of %d\n", count,
		       (4 * amount));
		return 1;
	}
}
Пример #7
0
void QObjectBenchmark::signal_slot_benchmark()
{
    QFETCH(int, type);

    Object singleObject;
    Object multiObject;
    singleObject.setObjectName(QLatin1String("single"));
    multiObject.setObjectName(QLatin1String("multi"));

    singleObject.connect(&singleObject, SIGNAL(signal0()), SLOT(slot0()));

    multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(slot0()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal1()));
    multiObject.connect(&multiObject, SIGNAL(signal1()), SLOT(slot1()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal2()));
    multiObject.connect(&multiObject, SIGNAL(signal2()), SLOT(slot2()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal3()));
    multiObject.connect(&multiObject, SIGNAL(signal3()), SLOT(slot3()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal4()));
    multiObject.connect(&multiObject, SIGNAL(signal4()), SLOT(slot4()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal5()));
    multiObject.connect(&multiObject, SIGNAL(signal5()), SLOT(slot5()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal6()));
    multiObject.connect(&multiObject, SIGNAL(signal6()), SLOT(slot6()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal7()));
    multiObject.connect(&multiObject, SIGNAL(signal7()), SLOT(slot7()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal8()));
    multiObject.connect(&multiObject, SIGNAL(signal8()), SLOT(slot8()));
    // multiObject.connect(&multiObject, SIGNAL(signal0()), SLOT(signal9()));
    multiObject.connect(&multiObject, SIGNAL(signal9()), SLOT(slot9()));

    if (type == 0) {
        QBENCHMARK {
            singleObject.slot0();
        }
    } else if (type == 1) {
Пример #8
0
int test_four()
{
	int retvalue;
	mode = 2;
	count = 0;
	if ((retvalue = signal1("replyer", 1)) != 1) {
		printf("Test 4,0 failed return value %d\n", retvalue);
		return 1;
	}
	if ((retvalue = signal2("replyer", 1, 2)) != 1) {
		printf("Test 2,1 failed return value %d\n", retvalue);
		return 1;
	}
	if ((retvalue = signal3("replyer", 1, 2, 3)) != 1) {
		printf("Test 2,2 failed return value %d\n", retvalue);
		return 1;
	}
	if ((retvalue = data("replyer", data_str, SIZEOF_DATA)) != 1) {
		printf("Test 2,3 failed return value %d\n", retvalue);
		return 1;
	}
	printf("Test 4 OK\n");
	return 0;
}
Пример #9
0
int test_one()
{
	int retvalue;
	mode = 0;
	count = 0;
	if ((retvalue = signal1("reply", 1)) != 2) {
		printf("Test 1,0 failed return value %d\n", retvalue);
		return 1;
	}
	if ((retvalue = signal2("reply", 1, 2)) != 2) {
		printf("Test 1,1 failed return value %d\n", retvalue);
		return 1;
	}
	if ((retvalue = signal3("reply", 1, 2, 3)) != 2) {
		printf("Test 1,2 failed return value %d\n", retvalue);
		return 1;
	}
	if ((retvalue = data("reply", data_str, SIZEOF_DATA)) != 2) {
		printf("Test 1,3 failed return value %d\n", retvalue);
		return 1;
	}
	printf("Test 1 OK\n");
	return 0;
}
Пример #10
0
void signal3_callback(char *proc, int value1, int value2, int value3)
{
	int retvalue = 0;
	if ((retvalue = signal3(proc, value1, value2, value3)))
		printf("replay:signal3 failed with %d\n", retvalue);
}
Пример #11
0
int main(int argc, char *argv[])
{
	int value1, value2, value3, mode = 0, retvalue, data_size;
	char dest_proc[PROC_NAME_SIZE], *datastr;

	memset(dest_proc, '\0', PROC_NAME_SIZE);
	/* Parse the parameters */
	if (argc < 4) {
		print_usage();
		exit(2);
	}
	if (!strcmp(argv[1], "-s1")) {
		if (argc != 4) {
			print_usage();
			exit(2);
		}
		mode = 1;
		value1 = atoi(argv[3]);
		strncpy(dest_proc, argv[2], (PROC_NAME_SIZE - 1));
	} else if (!strcmp(argv[1], "-s2")) {
		if (argc != 5) {
			print_usage();
			exit(2);
		}
		mode = 2;
		value1 = atoi(argv[3]);
		value2 = atoi(argv[4]);
		strncpy(dest_proc, argv[2], (PROC_NAME_SIZE - 1));
	} else if (!strcmp(argv[1], "-s3")) {
		if (argc != 6) {
			print_usage();
			exit(2);
		}
		mode = 3;
		value1 = atoi(argv[3]);
		value2 = atoi(argv[4]);
		value3 = atoi(argv[5]);
		strncpy(dest_proc, argv[2], (PROC_NAME_SIZE - 1));
	} else if (!strcmp(argv[1], "-d")) {
		if (argc != 4) {
			print_usage();
			exit(2);
		}
		mode = 4;
		data_size = strlen(argv[3]);
		strncpy(dest_proc, argv[2], (PROC_NAME_SIZE - 1));
		datastr = malloc(data_size);
		strncpy(datastr, argv[3], data_size);
	}
	if (mode == 0) {
		print_usage();
		exit(3);
	}

	/*set_print_level(CH_DEBUG); */
	init_memshare("memsend", 0, 0);

	switch (mode) {
	case 1:
		retvalue = signal1(dest_proc, value1);
		break;

	case 2:
		retvalue = signal2(dest_proc, value1, value2);
		break;

	case 3:
		retvalue = signal3(dest_proc, value1, value2, value3);
		break;

	case 4:
		retvalue = data(dest_proc, datastr, data_size);
		free(datastr);
		break;

	default:
		/* No place to be */
		break;
	}

	if (retvalue == 0)
		exit(0);

	if (retvalue == 1) {
		printf("The destination process %s is not present!\n",
		       dest_proc);
		exit(1);
	}

	/* No place to be */
	exit(2);
}