当前位置:网站首页>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
nameShould 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
nameIs 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 .
边栏推荐
- What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
- MySQL advanced SQL statement (1)
- Logical operator, displacement operator
- It's corrected. There's one missing < /script >, why doesn't the following template come out?
- JVM performance tuning and practical basic theory - medium
- Day05 branch and loop (II)
- Small program graduation design is based on wechat order takeout small program graduation design opening report function reference
- SRCNN:Learning a Deep Convolutional Network for Image Super-Resolution
- Will the memory of ParticleSystem be affected by maxparticles
- Méthode de calcul de la connexion MSSQL de la carte esp32c3
猜你喜欢

Maximum entropy model
![[leetcode daily question] a single element in an ordered array](/img/3a/2b465589b70cd6aeec08e79fcf40d4.jpg)
[leetcode daily question] a single element in an ordered array

Take you to master the formatter of visual studio code

LeetCode226. Flip binary tree

C import Xls data method summary II (save the uploaded file to the DataTable instance object)

Remember a lazy query error

MySQL deadly serial question 2 -- are you familiar with MySQL index?
![Jerry's modification setting status [chapter]](/img/23/d6eb521943b35e543a9681a98ad3be.jpg)
Jerry's modification setting status [chapter]

Do you know the eight signs of a team becoming agile?

MySQL statement learning record
随机推荐
Some other configurations on Huawei's spanning tree
Description of setting items of Jerry [chapter]
Infiltration learning diary day19
Douban scoring applet Part-3
Trading software programming
Small program graduation design is based on wechat order takeout small program graduation design opening report function reference
Related configuration commands of Huawei rip
Luogu p1309 Swiss wheel
Yyds dry goods inventory it's not easy to say I love you | use the minimum web API to upload files
Day05 branch and loop (II)
MySQL advanced SQL statement (1)
Software product download collection
Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
Ka! Why does the seat belt suddenly fail to pull? After reading these pictures, I can't stop wearing them
Hamburg University of Technology (tuhh) | intelligent problem solving as integrated hierarchical reinforcement learning
Conditional test, if, case conditional test statements of shell script
ES6 deletes an attribute in all array objects through map, deconstruction and extension operators
Reading notes - learn to write: what is writing?
Jerry's synchronous weather information to equipment [chapter]
It's corrected. There's one missing < /script >, why doesn't the following template come out?