示例#1
0
BOOL
init_profile(LPTSTR counter_name, PDH_profile *prof)
{

	BOOL ret = TRUE;

	prof->hQuery = NULL;
	prof->hCounter = NULL;
	prof->value = -1;

	__try {
		if (open_profile(prof)) {
			if (PdhValidatePath(counter_name) == ERROR_SUCCESS)
				ret = (PdhAddCounter(prof->hQuery, counter_name, 0,
					&(prof->hCounter)) == ERROR_SUCCESS);
			else
				ret = FALSE;
		} else {
			ret = FALSE;
		}
	}
	__except(EXCEPTION_EXECUTE_HANDLER) {
		ret = FALSE;
	}
	return (ret);
}
示例#2
0
文件: vmprof.c 项目: pypyjs/pypy
int vmprof_enable(int fd, long period_usec, int write_header, char *s,
				  int slen)
{
    assert(period_usec > 0);
    if (open_profile(fd, period_usec, write_header, s, slen) == -1) {
		return -1;
	}
    if (install_sigprof_handler() == -1) {
		return -1;
	}
    if (install_sigprof_timer(period_usec) == -1) {
		return -1;
	}
    if (install_pthread_atfork_hooks() == -1) {
        return -1;
    }
	return 0;
}
示例#3
0
int
main(int argc, char *argv[], char *env[])
{
    int i;
    void configure();
    FILE *pfp; /* current profile FP */
    GdkPixbuf* icon;
    ENTER;
    //printf("sizeof(gulong)=%d\n", sizeof(gulong));
    setlocale(LC_CTYPE, "");
    gtk_set_locale();
    gtk_init(&argc, &argv);
    XSetLocaleModifiers("");
    XSetErrorHandler((XErrorHandler) handle_error);
    icon = gdk_pixbuf_new_from_file(IMGPREFIX "star.png", NULL);
    if (icon) {
        gtk_window_set_default_icon(icon);
        g_object_unref(icon);
    }
    resolve_atoms();
    for (i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
            usage();
            exit(0);
        } else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
            printf("fbpanel %s\n", version);
            exit(0);
        } else if (!strcmp(argv[i], "--log")) {
            i++;
            if (i == argc) {
                ERR( "fbpanel: missing log level\n");
                usage();
                exit(1);
            } else {
                log_level = atoi(argv[i]);
            }
        } else if (!strcmp(argv[i], "--configure") || !strcmp(argv[i], "-C")) {
            config = 1;
        } else if (!strcmp(argv[i], "--profile") || !strcmp(argv[i], "-p")) {
            i++;
            if (i == argc) {
                ERR( "fbpanel: missing profile name\n");
                usage();
                exit(1);
            } else {
                cprofile = g_strdup(argv[i]);
            }
        } else {
            printf("fbpanel: unknown option - %s\n", argv[i]);
            usage();
            exit(1);
        }
    }

    gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
	IMGPREFIX);       
    signal(SIGUSR1, sig_usr);
    do {
        if (!(pfp = open_profile(cprofile)))
            exit(1);
        p = g_new0(panel, 1);
        g_return_val_if_fail (p != NULL, 1);
        if (!panel_start(p, pfp)) {
            ERR( "fbpanel: can't start panel\n");
            exit(1);
        }
        fclose(pfp);
        if (config)
            configure();
        gtk_main();
        panel_stop(p);
        g_free(p);
    } while (force_quit == 0);
    
    exit(0);
}