1
0
mirror of git://git.suckless.org/ubase synced 2024-12-23 23:22:47 +00:00

Add pagesize(1)

This program is useful in constructing portable shell scripts.
This commit is contained in:
sin 2013-10-29 15:36:18 +00:00
parent 0476f601b2
commit 97975ff092
2 changed files with 32 additions and 0 deletions

View File

@ -32,6 +32,7 @@ SRC = \
mkswap.c \
mount.c \
mountpoint.c \
pagesize.c \
pidof.c \
pivot_root.c \
ps.c \

31
pagesize.c Normal file
View File

@ -0,0 +1,31 @@
/* See LICENSE file for copyright and license details. */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
static void
usage(void)
{
eprintf("usage: %s\n", argv0);
}
int
main(int argc, char *argv[])
{
long pagesz;
ARGBEGIN {
default:
usage();
} ARGEND;
pagesz = sysconf(_SC_PAGESIZE);
if (pagesz < 0) {
pagesz = sysconf(_SC_PAGE_SIZE);
if (pagesz < 0)
enprintf(EXIT_FAILURE, "can't determine pagesize\n");
}
printf("%ld\n", pagesz);
return EXIT_SUCCESS;
}