Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Why a Program's First Argument Is the Name Itself? (cpu.land)
3 points by naman5a 3 months ago | hide | past | favorite | 1 comment


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:




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: