参数列表太长:Linux redhat 上的 /bin/sh

参数列表太长:Linux redhat 上的 /bin/sh

我有一个名为 test.sh 的脚本,我用它来运行如下,效果很好:-

/root/test.sh

然后我尝试使用 shc 编译器编译此脚本,如下所示,并带有警告:-

shc -v -r -T -f test.sh
shc: WARNING!!
Scripts of length near to (or higher than) the current System limit on
"maximum size of arguments to EXEC", could comprise its binary execution.
In the current System the call sysconf(_SC_ARG_MAX) returns -1 bytes
and your script "test.sh" is 155201 bytes length.
shc shll=sh
shc [-i]=-c
shc [-x]=exec '%s' "$@"
shc [-l]=
shc opts=
shc: cc  test.sh.x.c -o test.sh.x
shc: strip test.sh.x
shc: chmod go-r test.sh.x

由于此警告,我无法运行此编译文件:-

./test.sh.x
./test.sh.x: Argument list too long: /bin/sh

我如何增加 _SC_ARG_MAX 的限制以便我可以编译脚本。

答案1

您正在使用的程序无法_SC_ARG_MAX正确读取并将其报告为-1.

这意味着即使您尝试增加此值(其中包括修改系统头文件并至少重新编译内核和一些实用程序),它也可能会仍然没有读取到正确的值。

该消息是一个警告,这意味着它不是致命的。实用程序执行的任何操作很可能都正常。

系统配置变量ARG_MAX(具有符号常量 的值_SC_ARG_MAX)在 Ubuntu 上的值为 2097152,在 OpenBSD 上的值为 262144 ( getconf ARG_MAX)。您的值 155201 正好在其中。

我无法访问 RedHat 机器来查看该值可能是什么。

相关内容