当前位置:网站首页>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 .
边栏推荐
- Meta metauniverse female safety problems occur frequently. How to solve the related problems in the metauniverse?
- On Valentine's day, I code a programmer's exclusive Bing Dwen Dwen (including the source code for free)
- G3 boiler water treatment registration examination and G3 boiler water treatment theory examination in 2022
- Conditional test, if, case conditional test statements of shell script
- Write the first CUDA program
- Maximum likelihood method, likelihood function and log likelihood function
- Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
- Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
- Conditional statements of shell programming
- A fan summed up so many interview questions for you. There is always one you need!
猜你喜欢
Small program graduation project based on wechat video broadcast small program graduation project opening report function reference
Final consistency of MESI cache in CPU -- why does CPU need cache
51 MCU external interrupt
Huawei cloud micro certification Huawei cloud computing service practice has been stable
Small program graduation project based on wechat e-book small program graduation project opening report function reference
MySQL introduction - functions (various function statistics, exercises, details, tables)
The contact data on Jerry's management device supports reading and updating operations [articles]
Solution to the problem that jsp language cannot be recognized in idea
Life cycle of instance variables, static variables and local variables
[turn] solve the problem of "RSA public key not find" appearing in Navicat premium 15 registration
随机推荐
Install the pit that the electron has stepped on
TP5 automatic registration hook mechanism hook extension, with a complete case
How to view the computing power of GPU?
A fan summed up so many interview questions for you. There is always one you need!
C import Xls data method summary IV (upload file de duplication and database data De duplication)
ThinkPHP uses redis to update database tables
C import Xls data method summary II (save the uploaded file to the DataTable instance object)
Development of user-defined navigation bar in uniapp
Override and virtual of classes in C #
I don't know why it can't run in the project and how to change it
A. Min Max Swap
Pyinstaller packaging py script warning:lib not found and other related issues
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
Rearrangement of tag number of cadence OrCAD components and sequence number of schematic page
On Valentine's day, I code a programmer's exclusive Bing Dwen Dwen (including the source code for free)
Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
Gnupg website
Description of setting items of Jerry [chapter]
MySQL advanced (Advanced) SQL statement (I)