Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do the first two arguments in exec* functions contain redundant information?

Tags:

c

linux

I seem to miss something about those exec* functions.

The first argument is the filename or pathname of the executable to be executed.

The second argument (when l) or the first element of the second argument (when v) is also something similar. For example, here.

Do we really need to repeatedly duplicate redundancy? Thanks.

like image 541
Tim Avatar asked Dec 23 '22 02:12

Tim


1 Answers

They often do have the same information but it’s not redundant. The first is the name of the executable, but the second is what the executable sees as the name. For example, BusyBox uses links to provide different functionality based on the name with which the executable is called. So sometimes you want to give a different name to the called binary than the one on disk.

like image 122
Sami Kuhmonen Avatar answered Dec 31 '22 02:12

Sami Kuhmonen