executing a process with argc=0

Keeto picture Keeto · Nov 13, 2011 · Viewed 8.6k times · Source

Is it possible to execute a process whose argc = 0? I need to execute a program but it is extremely important for its argc to be equal to 0. Is there a way to do that? I tried to put 2^32 arguments in the command line so that it appears as if argc = 0 but there is a maximum limit to the number of arguments.

Answer

ibid picture ibid · Nov 13, 2011

You can write a program that calls exec directly; that allows you to specify the command-line arguments (including the program name) and lack thereof.