libslack(lim) - POSIX.1 limits module
#include <slack/std.h>
#include <slack/lim.h>
long limit_arg(void);
long limit_child(void);
long limit_tick(void);
long limit_group(void);
long limit_open(void);
long limit_stream(void);
long limit_tzname(void);
long limit_job(void);
long limit_save_ids(void);
long limit_version(void);
long limit_pcanon(const char *path);
long limit_fcanon(int fd);
long limit_canon(void);
long limit_pinput(const char *path);
long limit_finput(int fd);
long limit_input(void);
long limit_pvdisable(const char *path);
long limit_fvdisable(int fd);
long limit_vdisable(void);
long limit_plink(const char *path);
long limit_flink(int fd);
long limit_link(void);
long limit_pname(const char *path);
long limit_fname(int fd);
long limit_name(void);
long limit_ppath(const char *path);
long limit_fpath(int fd);
long limit_path(void);
long limit_ppipe(const char *path);
long limit_fpipe(int fd);
long limit_pnotrunc(const char *path);
long limit_fnotrunc(int fd);
long limit_notrunc(void);
long limit_pchown(const char *path);
long limit_fchown(int fd);
long limit_chown(void);
This module provides functions for simply and reliably obtaining a POSIX.1 limit for the current system or a usable default when a particular facility is unlimited on the current system. These functions always return a usable value.
long limit_arg(void)
Returns the maximum length of arguments to the exec(2) family of functions. If indeterminate, a usable value (131072) is returned.
long limit_child(void)
Returns the maximum number of simultaneous processes per user id. If indeterminate, a usable value (1024) is returned.
long limit_tick(void)
Returns the number of clock ticks per second. If indeterminate (which makes no sense), -1 is returned. This should never happen.
long limit_group(void)
Returns the maximum number of groups that a user may belong to. If indeterminate, a usable value (32) is returned.
long limit_open(void)
Returns the maximum number of files that a process can have open at any time. If indeterminate, a usable value (1024) is returned.
long limit_stream(void)
Returns the maximum number of streams that a process can have open at any time. If indeterminate, a usable value (1024) is returned.
long limit_tzname(void)
Returns the maximum number of bytes in a time zone name. If indeterminate, a usable value (3) is returned.
long limit_job(void)
Returns whether or not job control is supported.
long limit_save_ids(void)
Returns whether or not a process has a saved set-user-id and a saved set-group-id.
long limit_version(void)
Returns the year and month the POSIX.1 standard was approved in the format YYYYMML.
long limit_pcanon(const char *path)
Returns the maximum length of a formatted input line for the terminal referred to by path
. If indeterminate, a usable value (255) is returned.
long limit_fcanon(int fd)
Returns the maximum length of a formatted input line for the terminal referred to by fd
. If indeterminate, a usable value (255) is returned.
long limit_canon(void)
Returns the maximum length of a formatted input line for the controlling terminal (/dev/tty
). If indeterminate, a usable value (255) is returned.
long limit_pinput(const char *path)
Returns the maximum length of an input line for the terminal referred to by path
. If indeterminate, a usable value (255) is returned.
long limit_finput(int fd)
Returns the maximum length of an input line for the terminal referred to by fd
. If indeterminate, a usable value (255) is returned.
long limit_input(void)
Returns the maximum length of an input line for the controlling terminal (/dev/tty
). If indeterminate, a usable value (255) is returned.
long limit_pvdisable(const char *path)
Returns whether or not special character processing can be disabled for the terminal referred to by path
.
long limit_fvdisable(int fd)
Returns whether or not special character processing can be disabled for the terminal referred to by fd
.
long limit_vdisable(void)
Returns whether or not special character processing can be disabled for the controlling terminal (/dev/tty
).
long limit_plink(const char *path)
Returns the maximum number of links to the file represented by path
. If indeterminate, a usable value (32768) is returned.
long limit_flink(int fd)
Returns the maximum number of links to the file represented by fd
. If indeterminate, a usable value (32768) is returned.
long limit_link(void)
Returns the maximum number of links to the root directory (/
). If indeterminate, a usable value (32768) is returned.
long limit_pname(const char *path)
Returns the maximum length of a filename in the directory referred to by path
that the process can create. If indeterminate, a usable value (1024) is returned.
long limit_fname(int fd)
Returns the maximum length of a filename in the directory referred to by fd
that the process can create. If indeterminate, a usable value (1024) is returned.
long limit_name(void)
Returns the maximum length of a filename in the root directory (/
) that the process can create. If indeterminate, a usable value (1024) is returned.
long limit_ppath(const char *path)
Returns the maximum length of an absolute pathname (including the nul
character) when path
is the current directory. If indeterminate, a usable value (4096) is returned.
long limit_fpath(int fd)
Returns the maximum length of an absolute pathname (including the nul
character) when fd
refers to the current directory. If indeterminate, a usable value (4096) is returned.
long limit_path(void)
Returns the maximum length of an absolute pathname (including the nul
character). If indeterminate, a usable value (4096) is returned.
long limit_ppipe(const char *path)
Returns the size of the pipe buffer for the fifo referred to by path
. If indeterminate, a usable value (4096) is returned.
long limit_fpipe(int fd)
Returns the size of the pipe buffer for the pipe or fifo referred to by fd
. If indeterminate, a usable value (4096) is returned.
long limit_pnotrunc(const char *path)
Returns whether or not an error is generated when accessing filenames longer than the maximum filename length for the filesystem referred to by path
.
long limit_fnotrunc(int fd)
Returns whether or not an error is generated when accessing filenames longer than the maximum filename length for the filesystem referred to by fd
.
long limit_notrunc(void)
Returns whether or not an error is generated when accessing filenames longer than the maximum filename length for the root filesystem.
long limit_pchown(const char *path)
Returns whether or not chown(2) may be called on the file referred to by path
or the files contained in the directory referred to by path
.
long limit_fchown(int fd)
Returns whether or not chown(2) may be called on the file referred to by fd
or the files contained in the directory referred to by fd
.
long limit_chown(void)
Returns whether or not chown(2) may be called on the files contained in the root filesystem.
The functions that return a condition return 1
when the condition is true or 0
when it is false. All of the others either return the system limit indicated, or a predetermined, usable value when the indicated limit is indeterminate. These functions never return -1
.
MT-Safe
Store the current directory into allocated memory:
#include <slack/std.h>
#include <slack/lim.h>
int main()
{
long path_size = limit_path();
char *buf = malloc(path_size * sizeof(char));
if (!buf)
return EXIT_FAILURE;
printf("%s\n", getcwd(buf, path_size));
return EXIT_SUCCESS;
}
Close all file descriptors:
#include <slack/std.h>
#include <slack/lim.h>
int main()
{
int fd_limit = limit_open();
int fd;
for (fd = 0; fd < fd_limit; ++fd)
close(fd);
return EXIT_SUCCESS;
}
libslack(3), sysconf(2), pathconf(2), fpathconf(2), locker(3)
20230824 raf <raf@raf.org>