HackerTrans
TopNewTrendsCommentsPastAskShowJobs

naman5a

no profile record

Submissions

[untitled]

1 points·by naman5a·vor 11 Monaten·0 comments

Why a Program's First Argument Is the Name Itself?

cpu.land
3 points·by naman5a·vor 11 Monaten·1 comments

[untitled]

1 points·by naman5a·vor 2 Jahren·0 comments

comments

naman5a
·vor 11 Monaten·discuss
You know that convention where a program’s first argument is the name of the program? Behind the scenes the Program For Execution needs to go to Kernel where it will be executed by syscall .

The syscall for execution is execve and the call signature for that is int execve(const char filename, char const argv[], char *const envp[]);

The filename argument is passed to a getname() function, which copies the string from user space to kernel space and does some usage tracking things. It returns a filename struct, which is defined in include/linux/fs.h. It stores a pointer to the original string in user space as well as a new pointer to the value copied to kernel space:
naman5a
·letztes Jahr·discuss
Try to launch in ProductHunt and Appsumo , Good sites