diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -44,7 +44,6 @@ #include #include -#include #include #include #include @@ -258,7 +257,8 @@ } xo_emit("\n"); xo_close_list("key"); - xo_finish(); + if (xo_finish() < 0) + xo_err(EXIT_FAILURE, "stdout"); } void @@ -299,7 +299,7 @@ continue; } if ((vent = malloc(sizeof(struct varent))) == NULL) - errx(1, "malloc failed"); + xo_errx(1, "malloc failed"); vent->header = v->header; if (hp) { hp = strdup(hp); @@ -308,15 +308,15 @@ } vent->var = malloc(sizeof(*vent->var)); if (vent->var == NULL) - errx(1, "malloc failed"); + xo_errx(1, "malloc failed"); memcpy(vent->var, v, sizeof(*vent->var)); STAILQ_INSERT_TAIL(&varlist, vent, next_ve); } free(tempstr1); if (STAILQ_EMPTY(&varlist)) { - warnx("no valid keywords; valid keywords:"); + xo_warnx("no valid keywords; valid keywords:"); showkey(); - exit(1); + exit(EXIT_FAILURE); } } @@ -353,7 +353,7 @@ rflen = strlen(v->alias) + strlen(hp) + 2; realfmt = malloc(rflen); if (realfmt == NULL) - errx(1, "malloc failed"); + xo_errx(1, "malloc failed"); snprintf(realfmt, rflen, "%s=%s", v->alias, hp); parsefmt(realfmt, user); free(realfmt); @@ -361,7 +361,7 @@ return ((VAR *)NULL); } if (!v) { - warnx("%s: keyword not found", p); + xo_warnx("%s: keyword not found", p); eval = 1; } if (header) diff --git a/bin/ps/print.c b/bin/ps/print.c --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -49,7 +49,6 @@ #include #include -#include #include #include #include diff --git a/bin/ps/ps.c b/bin/ps/ps.c --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -61,7 +61,6 @@ #include #include -#include #include #include #include @@ -243,7 +242,7 @@ argc = xo_parse_args(argc, argv); if (argc < 0) - exit(1); + exit(EXIT_FAILURE); while ((ch = getopt(argc, argv, PS_ARGS)) != -1) switch (ch) { @@ -314,7 +313,7 @@ break; case 'L': showkey(); - exit(0); + exit(EXIT_SUCCESS); case 'l': parsefmt(lfmt, 0); _fmt = 1; @@ -460,7 +459,7 @@ usage(); } if (optfatal) - exit(1); /* Error messages already printed. */ + exit(EXIT_FAILURE); /* Error messages already printed. */ if (xkeep < 0) /* Neither -X nor -x was specified. */ xkeep = xkeep_implied; @@ -635,8 +634,9 @@ if (nkept == 0) { printheader(); - xo_finish(); - exit(1); + if (xo_finish() < 0) + xo_err(EXIT_FAILURE, "stdout"); + exit(EXIT_FAILURE); } /* @@ -720,7 +720,8 @@ } xo_close_list("process"); xo_close_container("process-information"); - xo_finish(); + if (xo_finish() < 0) + xo_err(EXIT_FAILURE, "stdout"); free_list(&gidlist); free_list(&jidlist); @@ -790,14 +791,14 @@ int tempid; if (*elem == '\0') { - warnx("Invalid (zero-length) jail id"); + xo_warnx("Invalid (zero-length) jail id"); optfatal = 1; return (0); /* Do not add this value. */ } tempid = jail_getid(elem); if (tempid < 0) { - warnx("Invalid %s: %s", inf->lname, elem); + xo_warnx("Invalid %s: %s", inf->lname, elem); optfatal = 1; return (0); } @@ -1463,5 +1464,5 @@ " [-G gid[,gid...]] [-J jid[,jid...]] [-M core] [-N system]", " [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]", " ps [--libxo] -L"); - exit(1); + exit(EXIT_FAILURE); }