What happens in user space when the `execl()` function is called? Describe the role of the GNU C Library (glibc) and how arguments and environment variables are prepared.
When execl function is called, firstly the execl function prepares the arguments for the new executable, for e.g the execl command looks like:
int execl("/bin/ls","ls","-l",(char*)0);
Here the argument specified to it is the pathname, first argument is the pathname itself and second argument is a argument to the first argument. (char*)0 indicates the termination of argument list. The glibc library calls the execve function, which is the actual system call that the kernel understands, while execl and other variants are just wrappers. The call to execve involves passing the path, arguments and environment variables, these variables are prepared by execl in this case.