Download raw body.
PATCH: use sysconf(_SC_PAGESIZE) in bin/ps
There is no point in doing this.
getpagesize() is never going away, because it has no risks. This is
not strcpy() or gets().
Secondly, everyone despises hates sysconf.
> Hello,
>
> The current version of ps(1) still uses the obsolete getpagesize()
> function. Following the recommendation in getpagesize(3), this patch
> migrates the code to sysconf(_SC_PAGESIZE).
>
> I have updated the 'pagesize' variable to a 'long' to match the
> return type of sysconf() and ensure consistency in memory
> calculations within the pgtok() macro.
>
> Tested on OpenBSD 7.8 x86_64.
>
> Index: bin/ps/extern.h
> --- bin/ps/extern.h
> +++ bin/ps/extern.h
> @@ -38,7 +38,7 @@
>
> extern struct varent var[];
> extern int eval;
> -extern int pagesize;
> +extern long pagesize;
> extern int termwidth;
> extern int totwidth;
>
> Index: bin/ps/ps.c
> --- bin/ps/ps.c
> +++ bin/ps/ps.c
> @@ -58,7 +58,7 @@
>
> struct varent var[];
> int eval;
> -int pagesize;
> +long pagesize;
> int termwidth;
> int totwidth;
> int needenv, needuser, oneline;
> @@ -204,7 +204,9 @@
> if (setlocale(LC_CTYPE, "") == NULL)
> warnx("invalid locale");
>
> - pagesize = getpagesize();
> + pagesize = sysconf(_SC_PAGESIZE);
> + if (pagesize == -1)
> + err(1, "sysconf _SC_PAGESIZE");
>
> while ((ch = getopt(argc, argv, getoptstr)) != -1) {
> switch (ch) {
>
PATCH: use sysconf(_SC_PAGESIZE) in bin/ps