当前位置:网站首页>15. System limitations and options
15. System limitations and options
2022-07-04 01:59:00 【666QAQ】
Concept
Constant value during operation
Runtime constant value refers to a certain limit , If already in <limits.h>
In the definition of , be Fixed for implementation . But it's time to The value is uncertain ( Because this value may depend on the available memory space ), So in the <limits.h>
Its definition will be ignored in .
This case can be used sysconf()
Get at run time .
Value can be added at run time
The value that can be added at runtime refers to a certain limit , Relative to a specific implementation Its value is fixed , And all systems running this implementation At least this minimum value should be supported , However , This minimum value may be increased when a particular system is running , have access to sysconf()
To get the actual value supported by the system .
Pathname variable value
The path name variable refers to the path name ( file 、 Catalog 、 Terminals, etc ) Related restrictions , Every restriction It may be a constant relative to a system implementation , It may also vary from file system to file system . In cases where restrictions may change due to pathnames , Applications can use pathconf()
、fpathconf()
To get the value .
stay shell Get restrictions and options :getconf
stay shell in , have access to getconf
Command to get a specific UNIX Limitations and options already implemented in the system .
The format is generally as follows :
$getconf ARG_MAX
2097152
$getconf NAME_MAX /boot
255
Get system limits at runtime
sysconf()
、pathconf()
、fpathconf()
It is called by the application to check the limitations and options of the system implementation .
#include <unistd.h>
long sysconf(int name);
Returns value of limit specified by name,
or -1 if limit is indeterminate or an error occurred
- Parameters
name
Should be defined on<unistd.h>
In the document_SC_
One of a series of constants , The limit value will be returned as the result of the day function . - If a certain limit cannot be determined , be
sysconf()
return -1. - If an error occurs during the call , And will return to -1( The only specified error is EINVAL, Express name Invalid ).
To distinguish the return -1 The situation of , You should set errno
Set to 0, If the call returns -1, And take it with you errno
Values are not for 0, be sysconf()
An error occurred during the call .
The limit value will not change during the process .
Get file related restrictions at runtime
#include <unistd.h>
long pathconf(const char *pathname, int name);
long fpathconf(int fd, int name);
Both returns value of limit specified by name,
or -1 if limit is indeterminate or an error occured.
pathconf()
Andfpahconf()
The only difference is the way files or directories are specified , The former is the path name method , The latter is the file descriptor .- Parameters
name
Is defined in<unistd.h>
Medium_PC_
Series constants , The value of the limit will be returned as the result of the function call .
The limit value may change during the operation in the village , For example, when remounting the file system .
Uncertain limits
Sometimes system implementations do not define some system limitations as limiting constants ( such as PATH_MAX), also sysconf()
or pathconf()
When the corresponding limit is returned, it will be classified as uncertain . Regarding this ,
- Reference resources SUSv3 Specified minimum limit , Combined with practice .
- Omit the restriction check , Judge according to the error result and try again / modify .
- Write your own program or function to infer or estimate the limit value .
边栏推荐
- Is Shengang securities company as safe as other securities companies
- C import Xls data method summary V (complete code)
- Experimental animal models - current market situation and future development trend
- Related configuration commands of Huawei rip
- Lightweight Pyramid Networks for Image Deraining
- Final consistency of MESI cache in CPU -- why does CPU need cache
- [leetcode daily question] a single element in an ordered array
- Idea if a class cannot be found, it will be red
- Magical usage of edge browser (highly recommended by program ape and student party)
- Gee: create a new feature and set corresponding attributes
猜你喜欢
Bacteriostatic circle scanning correction template
Douban scoring applet Part-3
What is the intelligent monitoring system of sewage lifting pump station and does it play a big role
Audio resource settings for U3D resource management
The reasons why QT fails to connect to the database and common solutions
Pyinstaller packaging py script warning:lib not found and other related issues
Remember a lazy query error
A fan summed up so many interview questions for you. There is always one you need!
Will the memory of ParticleSystem be affected by maxparticles
Small program graduation project based on wechat reservation small program graduation project opening report reference
随机推荐
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
Portapack application development tutorial (XVII) nRF24L01 launch C
MPLS③
Jerry's update contact [article]
Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
Final consistency of MESI cache in CPU -- why does CPU need cache
Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
Méthode de calcul de la connexion MSSQL de la carte esp32c3
Servlet simple verification code generation
51 single chip microcomputer timer 2 is used as serial port
Writeup (real questions and analysis of ciscn over the years) of the preliminary competition of national college students' information security competition
Feign implements dynamic URL
Small program graduation design is based on wechat order takeout small program graduation design opening report function reference
Magical usage of edge browser (highly recommended by program ape and student party)
Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference
String & memory function (detailed explanation)
Ceramic metal crowns - current market situation and future development trend
What is the intelligent monitoring system of sewage lifting pump station and does it play a big role
Life cycle of instance variables, static variables and local variables
Why is the operation unsuccessful (unresolved) uncaught syntaxerror: invalid or unexpected token (resolved)