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
557905569d
commit
ac4b8a1ce4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362707
@ -41,7 +41,7 @@ extern fixpt_t ccpu;
|
|||||||
extern int cflag, eval, fscale, nlistread, rawcpu;
|
extern int cflag, eval, fscale, nlistread, rawcpu;
|
||||||
extern unsigned long mempages;
|
extern unsigned long mempages;
|
||||||
extern time_t now;
|
extern time_t now;
|
||||||
extern int showthreads, sumrusage, termwidth, smp;
|
extern int showthreads, sumrusage, termwidth;
|
||||||
extern STAILQ_HEAD(velisthead, varent) varlist;
|
extern STAILQ_HEAD(velisthead, varent) varlist;
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
@ -555,9 +555,6 @@ cpunum(KINFO *k, VARENT *ve __unused)
|
|||||||
{
|
{
|
||||||
char *cpu;
|
char *cpu;
|
||||||
|
|
||||||
if (!smp)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
if (k->ki_p->ki_stat == SRUN && k->ki_p->ki_oncpu != NOCPU) {
|
if (k->ki_p->ki_stat == SRUN && k->ki_p->ki_oncpu != NOCPU) {
|
||||||
asprintf(&cpu, "%d", k->ki_p->ki_oncpu);
|
asprintf(&cpu, "%d", k->ki_p->ki_oncpu);
|
||||||
} else {
|
} else {
|
||||||
|
15
bin/ps/ps.c
15
bin/ps/ps.c
@ -105,7 +105,6 @@ int rawcpu; /* -C */
|
|||||||
int sumrusage; /* -S */
|
int sumrusage; /* -S */
|
||||||
int termwidth; /* Width of the screen (0 == infinity). */
|
int termwidth; /* Width of the screen (0 == infinity). */
|
||||||
int showthreads; /* will threads be shown? */
|
int showthreads; /* will threads be shown? */
|
||||||
int smp; /* multi-processor support */
|
|
||||||
|
|
||||||
struct velisthead varlist = STAILQ_HEAD_INITIALIZER(varlist);
|
struct velisthead varlist = STAILQ_HEAD_INITIALIZER(varlist);
|
||||||
|
|
||||||
@ -158,7 +157,6 @@ static void saveuser(KINFO *);
|
|||||||
static void scanvars(void);
|
static void scanvars(void);
|
||||||
static void sizevars(void);
|
static void sizevars(void);
|
||||||
static void pidmax_init(void);
|
static void pidmax_init(void);
|
||||||
static void smp_init(void);
|
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
|
|
||||||
static char dfmt[] = "pid,tt,state,time,command";
|
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]);
|
argv[1] = kludge_oldps_options(PS_ARGS, argv[1], argv[2]);
|
||||||
|
|
||||||
pidmax_init();
|
pidmax_init();
|
||||||
smp_init();
|
|
||||||
|
|
||||||
all = descendancy = _fmt = nselectors = optfatal = 0;
|
all = descendancy = _fmt = nselectors = optfatal = 0;
|
||||||
prtheader = showthreads = wflag = xkeep_implied = 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
|
static void __dead2
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user