Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/procstat/procstat_args.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 24 Lines | |||||
#include <libprocstat.h> | #include <libprocstat.h> | ||||
#include <limits.h> | #include <limits.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include "procstat.h" | #include "procstat.h" | ||||
static void | void | ||||
do_args(struct procstat *procstat, struct kinfo_proc *kipp, int env) | procstat_args(struct procstat *procstat, struct kinfo_proc *kipp) | ||||
{ | { | ||||
int i; | int i; | ||||
char **args; | char **args; | ||||
if (!hflag) { | if (!hflag) { | ||||
printf("%5s %-16s %-53s\n", "PID", "COMM", | xo_emit("{T:/%5s %-16s %-53s}\n", "PID", "COMM", "ARGS"); | ||||
env ? "ENVIRONMENT" : "ARGS"); | |||||
} | } | ||||
args = env ? procstat_getenvv(procstat, kipp, 0) : | args = procstat_getargv(procstat, kipp, 0); | ||||
procstat_getargv(procstat, kipp, 0); | |||||
printf("%5d %-16s", kipp->ki_pid, kipp->ki_comm); | xo_emit("{k:process_id/%5d/%d} {:command/%-16s/%s}", kipp->ki_pid, kipp->ki_comm); | ||||
marcel: This line is longer than 80 characters. You may want to break it, like:
```
xo_emit("{k… | |||||
if (args == NULL) { | if (args == NULL) { | ||||
printf(" -\n"); | xo_emit(" {d:args/-}\n"); | ||||
return; | return; | ||||
} | } | ||||
xo_open_list("arguments"); | |||||
for (i = 0; args[i] != NULL; i++) | for (i = 0; args[i] != NULL; i++) | ||||
printf(" %s", args[i]); | xo_emit(" {l:args/%s}", args[i]); | ||||
printf("\n"); | xo_close_list("arguments"); | ||||
xo_emit("\n"); | |||||
} | } | ||||
void | void | ||||
procstat_args(struct procstat *procstat, struct kinfo_proc *kipp) | procstat_env(struct procstat *procstat, struct kinfo_proc *kipp) | ||||
{ | { | ||||
do_args(procstat, kipp, 0); | int i; | ||||
char **envs; | |||||
if (!hflag) { | |||||
xo_emit("{T:/%5s %-16s %-53s}\n", "PID", "COMM", "ENVIRONMENT"); | |||||
} | } | ||||
void | envs = procstat_getenvv(procstat, kipp, 0); | ||||
procstat_env(struct procstat *procstat, struct kinfo_proc *kipp) | |||||
{ | xo_emit("{k:process_id/%5d/%d} {:command/%-16s/%s}", kipp->ki_pid, kipp->ki_comm); | ||||
Not Done Inline ActionsThis line is longer than 80 characters. You may want to break it, like: xo_emit("{k:process_id/%5d/%d} {:command/%-16s/%s}", kipp->ki_pid, kipp->ki_comm); marcel: This line is longer than 80 characters. You may want to break it, like:
```
xo_emit("{k… | |||||
do_args(procstat, kipp, 1); | |||||
if (envs == NULL) { | |||||
xo_emit(" {d:env/-}\n"); | |||||
return; | |||||
} | |||||
xo_open_list("environment"); | |||||
for (i = 0; envs[i] != NULL; i++) | |||||
xo_emit(" {l:env/%s}", envs[i]); | |||||
xo_close_list("environment"); | |||||
xo_emit("\n"); | |||||
} | } |
This line is longer than 80 characters. You may want to break it, like: