Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

executing a process with argc=0

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.

like image 476
Keeto Avatar asked Nov 13 '11 18:11

Keeto


People also ask

Can argc be 0 C++?

Yes, it can be zero, meaning that argv[0] == NULL . It's a convention that argv[0] is the name of the program. You can have argc == 0 if you launch yourself the binary, like with execve family and don't give any argument.

What does argv 0 mean?

By convention, argv[0] is the command with which the program is invoked. argv[1] is the first command-line argument. The last argument from the command line is argv[argc - 1] , and argv[argc] is always NULL.

What does argc 1 mean?

argc is the count of arguments, and argv is an array of the strings. The program itself is the first argument, argv[0] , so argc is always at least 1.


1 Answers

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.

like image 180
ibid Avatar answered Sep 21 '22 05:09

ibid