int EventSet = PAPI_NULL;
unsigned long pid;
pid = fork();
if (pid <= 0)
exit(1);
if (PAPI_create_eventset(&EventSet) != PAPI_OK)
exit(1);
/* Add Total Instructions Executed to our EventSet */
if (PAPI_add_event(EventSet, PAPI_TOT_INS) != PAPI_OK)
exit(1);
/* Attach this EventSet to the forked process */
if (PAPI_attach(EventSet, pid) != PAPI_OK)
exit(1);