Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/procstat/procstat_bin.c
/*- | /*- | ||||
* Copyright (c) 2007 Robert N. M. Watson | * Copyright (c) 2007 Robert N. M. Watson | ||||
* Copyright (c) 2015 Allan Jude <allanjude@freebsd.org> | |||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
Show All 30 Lines | |||||
void | void | ||||
procstat_bin(struct procstat *prstat, struct kinfo_proc *kipp) | procstat_bin(struct procstat *prstat, struct kinfo_proc *kipp) | ||||
{ | { | ||||
int osrel; | int osrel; | ||||
static char pathname[PATH_MAX]; | static char pathname[PATH_MAX]; | ||||
if (!hflag) | if (!hflag) | ||||
printf("%5s %-16s %8s %s\n", "PID", "COMM", "OSREL", "PATH"); | xo_emit("{T:/%5s %-16s %8s %s}\n", "PID", "COMM", "OSREL", | ||||
"PATH"); | |||||
if (procstat_getpathname(prstat, kipp, pathname, sizeof(pathname)) != 0) | if (procstat_getpathname(prstat, kipp, pathname, sizeof(pathname)) != 0) | ||||
return; | return; | ||||
if (strlen(pathname) == 0) | if (strlen(pathname) == 0) | ||||
strcpy(pathname, "-"); | strcpy(pathname, "-"); | ||||
if (procstat_getosrel(prstat, kipp, &osrel) != 0) | if (procstat_getosrel(prstat, kipp, &osrel) != 0) | ||||
return; | return; | ||||
printf("%5d ", kipp->ki_pid); | xo_emit("{k:process_id/%5d/%d} ", kipp->ki_pid); | ||||
printf("%-16s ", kipp->ki_comm); | xo_emit("{:command/%-16s/%s} ", kipp->ki_comm); | ||||
printf("%8d ", osrel); | xo_emit("{:osrel/%8d/%d} ", osrel); | ||||
printf("%s\n", pathname); | xo_emit("{:pathname/%s}\n", pathname); | ||||
} | } |