0

I am having a script named as test.sh, which I use to run as below, which works fine:-

/root/test.sh

Then i tried to compile this script using the shc compiler as below with Warning:-

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

as a result of this warning i am not able to run this compiled file:-

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

How can i increase the limit of _SC_ARG_MAX so that i can compile the scripts.

3
  • As you can see: 1) It's a warning, not an error, and 2) the value -1 for the current _SC_ARG_MAX is nonsensical. Also 3) You would have to change the limit in one of the system header files and recompile everything that uses that header.
    – Kusalananda
    Sep 25 '17 at 16:00
  • The -1 thing I alluded to above means no matter what you increase _SC_ARG_MAX to, it would likely still complain as it doesn't seem to read the value correctly.
    – Kusalananda
    Sep 25 '17 at 16:56
  • sysconf(3) returns -1 only in case of an error. _SC_ARG_MAX is required by POSIX, so you're looking at a bug either in shc or in your libc. Sep 25 '17 at 17:07
1

The program that you are using is not reading _SC_ARG_MAX correctly and reports it as -1.

This means that even if you tried to increase this value (which would include fiddling in the system header files and recompiling at least the kernel and a few utilities), it would probably still not read the correct value.

The message is a warning, which means that it's not fatal. It is likely that whatever operation the utility preformed went ok.

The system configuration variable ARG_MAX (which has the value of the symbolic constant _SC_ARG_MAX) has the value 2097152 on Ubuntu and 262144 on OpenBSD (getconf ARG_MAX). Your value, 155201, is well within those.

I don't have access to a RedHat machine to see what this value may be there.

2
  • I am on Red Hat Enterprise Linux Server release 6.6 Current Value in limit.h is as below:- #define ARG_MAX 131072 /* # bytes of args + environ for exec() */
    – jassi10781
    Sep 26 '17 at 4:30
  • My project works fine in linux with a smaller arg_max but fails in openbsd.
    – Richard
    Jan 6 '20 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.