- if ((usp = (struct usave *)calloc(1, sizeof(struct usave))) == NULL) {
- (void)fprintf(stderr, "ps: %s\n", strerror(errno));
- exit(1);
- }
- ki->ki_u = usp;
- up = kvm_getu(ki->ki_p);
+ if (kvm_read(kd, (u_long)&KI_PROC(ki)->p_addr->u_stats,
+ (char *)&pstats, sizeof(pstats)) == sizeof(pstats)) {
+ /*
+ * The u-area might be swapped out, and we can't get
+ * at it because we have a crashdump and no swap.
+ * If it's here fill in these fields, otherwise, just
+ * leave them 0.
+ */
+ usp->u_start = pstats.p_start;
+ usp->u_ru = pstats.p_ru;
+ usp->u_cru = pstats.p_cru;
+ usp->u_valid = 1;
+ } else
+ usp->u_valid = 0;