ps(1): don't try to handle non-SMP systems
As reported by kib, sysctl machdep.smp_active doesn't exist and on UP we return CPU 0 for all threads anyway. Reported by: kib
This commit is contained in:
parent
0730d174fe
commit
ee18d3b109
@ -41,7 +41,7 @@ extern fixpt_t ccpu;
|
||||
extern int cflag, eval, fscale, nlistread, rawcpu;
|
||||
extern unsigned long mempages;
|
||||
extern time_t now;
|
||||
extern int showthreads, sumrusage, termwidth, smp;
|
||||
extern int showthreads, sumrusage, termwidth;
|
||||
extern STAILQ_HEAD(velisthead, varent) varlist;
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
@ -555,9 +555,6 @@ cpunum(KINFO *k, VARENT *ve __unused)
|
||||
{
|
||||
char *cpu;
|
||||
|
||||
if (!smp)
|
||||
return (NULL);
|
||||
|
||||
if (k->ki_p->ki_stat == SRUN && k->ki_p->ki_oncpu != NOCPU) {
|
||||
asprintf(&cpu, "%d", k->ki_p->ki_oncpu);
|
||||
} else {
|
||||
|
15
bin/ps/ps.c
15
bin/ps/ps.c
@ -105,7 +105,6 @@ int rawcpu; /* -C */
|
||||
int sumrusage; /* -S */
|
||||
int termwidth; /* Width of the screen (0 == infinity). */
|
||||
int showthreads; /* will threads be shown? */
|
||||
int smp; /* multi-processor support */
|
||||
|
||||
struct velisthead varlist = STAILQ_HEAD_INITIALIZER(varlist);
|
||||
|
||||
@ -158,7 +157,6 @@ static void saveuser(KINFO *);
|
||||
static void scanvars(void);
|
||||
static void sizevars(void);
|
||||
static void pidmax_init(void);
|
||||
static void smp_init(void);
|
||||
static void usage(void);
|
||||
|
||||
static char dfmt[] = "pid,tt,state,time,command";
|
||||
@ -228,7 +226,6 @@ main(int argc, char *argv[])
|
||||
argv[1] = kludge_oldps_options(PS_ARGS, argv[1], argv[2]);
|
||||
|
||||
pidmax_init();
|
||||
smp_init();
|
||||
|
||||
all = descendancy = _fmt = nselectors = optfatal = 0;
|
||||
prtheader = showthreads = wflag = xkeep_implied = 0;
|
||||
@ -1459,18 +1456,6 @@ pidmax_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
smp_init(void)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
size = sizeof(smp);
|
||||
if ((sysctlbyname("machdep.smp_active", &smp, &size, NULL, 0) != 0 &&
|
||||
sysctlbyname("kern.smp.active", &smp, &size, NULL, 0) != 0) ||
|
||||
size != sizeof(smp))
|
||||
smp = 0;
|
||||
}
|
||||
|
||||
static void __dead2
|
||||
usage(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user