Easy c debugging question

walt wa1ter at myrealbox.com
Tue Mar 29 06:09:48 PST 2005


I wrote this trivial c program to practice using libkinfo:

#include <sys/param.h>
#include <kinfo.h>
int main()
{
struct kinfo_cputime *k;
kinfo_get_sched_cputime(k);

printf("user=%16d\n", k->cp_user);
printf("nice=%16d\n", k->cp_nice);
printf("sys=%16d\n", k->cp_sys);
printf("intr=%16d\n", k->cp_intr);
printf("idle=%16d\n", k->cp_idle);
}

It works as I expected when compiled with dynamic linking,
but it dumps core when statically linked.  gdb tells me
it exits at the first printf with 'code 026', which means
nothing to me.

Any hints what I'm doing wrong?





More information about the Users mailing list