Thank you. But none of the respondents gave the correct answer. It’s my fault that I didn’t provide all the information. In fact, there is nothing wrong with the code itself, but there is a section setrlimit in front of it to limit memory usage. Due to a configuration error, the upper limit of memory is too small, so that the string in argv cannot even be stored. The error is ridiculous. The error is ridiculous. The error is ridiculous. But at least we know that argv is not occupying the memory of the current process. :P
As you can see, the current environment variables are output here. If your config->args does not end with NULL and you have a lot of environment variables, will this happen?
I didn’t read your code in detail, I just briefly looked at the execvp calling part. You directly called the execvp function without judging whether raise was successful. But raise this function is used to send a signal to the executing program. In other words, as long as you call execvp here, the SIGUSR1 signal will be sent without any accident. Because errno is a global variable, so here, it does not mean that it is set by execvp.
Thank you.
But none of the respondents gave the correct answer. It’s my fault that I didn’t provide all the information.
In fact, there is nothing wrong with the code itself, but there is a section
setrlimit
in front of it to limit memory usage. Due to a configuration error, the upper limit of memory is too small, so that the string inargv
cannot even be stored.The error is ridiculous.
The error is ridiculous.
The error is ridiculous.
But at least we know that
argv
is not occupying the memory of the current process. :PLook at the code below
Compile and run, the output is as follows
Modify the code so that the parameters of
execvp
do not end withNULL
Compile and run
As you can see, the current environment variables are output here.
If your config->args does not end with
NULL
and you have a lot of environment variables, will this happen?I didn’t read your code in detail, I just briefly looked at theexecvp
calling part.You directly called theexecvp
function without judging whetherraise
was successful.Butraise
this function is used to send a signal to the executing program. In other words, as long as you callexecvp
here, theSIGUSR1
signal will be sent without any accident.Becauseerrno
is a global variable, so here, it does not mean that it is set byexecvp
.Put ab in the background. If there are still errors, it must be an error in ab execution
Looks like the last element of the
config->args
pointer array is not set toNULL
.execvp
determines the end of the list based on the null pointer.For example: