Esempio n. 1
0
int main(int arg, char *args[])
{
	if (arg < 2)//如果没有参数,main函数返回
	{
		printf("usage:qqserverd port\n");
		return -1;
	}

	int iport = atoi(args[1]);
	if (iport == 0)
	{
		printf("port %d is invalid\n", iport);
		return -1;
	}

	setdaemon();//进入daemon状态
	work w(iport);

	printf("qqserver is begin\n");

	signal1(SIGINT, catch_Signal);
	signal1(SIGPIPE, catch_Signal);
	w.run();
	printf("qqserver is end\n");
	return 0;
}
Esempio n. 2
0
int main(void)
{
	setdaemon(); //把进程设置成daemon状态
	signal1(SIGINT,catch_Signal);//捕捉Signal 信号
	signal1(SIGPIPE,catch_Signal);//捕捉Signal 信号
	while(1)
	{
		puts("hello world");
		sleep(1);

	}
	return EXIT_SUCCESS;
}
Esempio n. 3
0
s_paus(char *s, ftnlen n)
#endif
{
	fprintf(stderr, "PAUSE ");
	if(n > 0)
		fprintf(stderr, " %.*s", (int)n, s);
	fprintf(stderr, " statement executed\n");
	if( isatty(fileno(stdin)) )
		s_1paus(stdin);
	else {
#if (defined (MSDOS) && !defined (GO32)) || defined (_WIN32)
		FILE *fin;
		fin = fopen("con", "r");
		if (!fin) {
			fprintf(stderr, "s_paus: can't open con!\n");
			fflush(stderr);
			exit(1);
			}
		s_1paus(fin);
		fclose(fin);
#else
		fprintf(stderr,
		"To resume execution, execute a   kill -%d %d   command\n",
			PAUSESIG, getpid() );
		signal1(PAUSESIG, waitpause);
		fflush(stderr);
		pause();
#endif
		}
	fprintf(stderr, "Execution resumes after PAUSE.\n");
	fflush(stderr);
	return 0; /* NOT REACHED */
#ifdef __cplusplus
	}
Esempio n. 4
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;
	}
}
Esempio n. 5
0
void signal1_callback(char *proc, int value)
{
	int retvalue = 0;
	if (value == 666) {
		system("./memsend -s1 memshare 8");
		system("./memsend -s2 memshare 12 24");
		system("./memsend -s3 memshare 48 96 192");
		return;
	}
	if ((retvalue = signal1(proc, value)))
		printf("replay:signal1 failed with %d\n", retvalue);
}
Esempio n. 6
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) {
Esempio n. 7
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;
	}
}
Esempio n. 8
0
 void
f_setsig()
{
signal1(SIGFPE, sigfdie);	/* ignore underflow, enable overflow */
#ifdef SIGIOT
signal1(SIGIOT, sigidie);
#endif
#ifdef SIGTRAP
signal1(SIGTRAP, sigtrdie);
#endif
#ifdef SIGQUIT
if(signal1(SIGQUIT,sigqdie) == SIG_IGN)
	signal1(SIGQUIT, SIG_IGN);
#endif
if(signal1(SIGINT, sigindie) == SIG_IGN)
	signal1(SIGINT, SIG_IGN);
signal1(SIGTERM,sigtdie);

#ifdef pdp11
	ldfps(01200); /* detect overflow as an exception */
#endif
}
Esempio n. 9
0
int test_six()
{
	int retvalue;
	mode = 4;
	count = 0;

	if ((retvalue = signal1("reply", 666)) != 0) {
		printf("Test 6,0 failed return value %d\n", retvalue);
		return 1;
	}

	sleep(3);
	if (count == 3) {
		printf("Test 6 OK\n");
		return 0;
	} else {
		printf("Test 6 failed %d\n", count);
		return 1;
	}
}
Esempio n. 10
0
s_paus(char *s, ftnlen n)
#endif
{
	fprintf(stderr, "PAUSE ");
	if(n > 0)
		fprintf(stderr, " %.*s", (int)n, s);
	fprintf(stderr, " statement executed\n");
	if( isatty(fileno(stdin)) )
		s_1paus(stdin);
	else {
#ifdef MSDOS
		FILE *fin;
		fin = fopen("con", "r");
		if (!fin) {
			fprintf(stderr, "s_paus: can't open con!\n");
			fflush(stderr);
			exit(1);
			}
		s_1paus(fin);
		fclose(fin);
		
/* IMT 14Aug97  Create appropriate pause mechanism for MacOS */
#elif defined(TPM_F2C) || defined(SPM_F2C) || defined(CW_F2C_MAC) 
		fprintf( stderr, "To resume execution, click the mouse button.\n" );
		fflush( stderr );
		pause();			/* Special MacOS version */
		
#else
		fprintf(stderr,
		"To resume execution, execute a   kill -%d %d   command\n",
			PAUSESIG, getpid() );
		signal1(PAUSESIG, waitpause);
		fflush(stderr);
		pause();
#endif
		}
	fprintf(stderr, "Execution resumes after PAUSE.\n");
	fflush(stderr);
	return 0; /* NOT REACHED */
#ifdef __cplusplus
	}
Esempio n. 11
0
main(int argc, char **argv)
#endif
{
xargc = argc;
xargv = argv;
signal1(SIGFPE, sigfdie);	/* ignore underflow, enable overflow */
#ifdef SIGIOT
signal1(SIGIOT, sigidie);
#endif
#ifdef SIGTRAP
signal1(SIGTRAP, sigtrdie);
#endif
#ifdef SIGQUIT
if(signal1(SIGQUIT,sigqdie) == SIG_IGN)
	signal1(SIGQUIT, SIG_IGN);
#endif
if(signal1(SIGINT, sigindie) == SIG_IGN)
	signal1(SIGINT, SIG_IGN);
signal1(SIGTERM,sigtdie);

#ifdef pdp11
	ldfps(01200); /* detect overflow as an exception */
#endif

f_init();
#ifndef NO_ONEXIT
ONEXIT(f_exit);
#endif
MAIN__();
#ifdef NO_ONEXIT
f_exit();
#endif
exit(0);	/* exit(0) rather than return(0) to bypass Cray bug */
return 0;	/* For compilers that complain of missing return values; */
		/* others will complain that this is unreachable code. */
}
Esempio n. 12
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) {
Esempio n. 13
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;
}
Esempio n. 14
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;
}
Esempio n. 15
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);
}