My question is how cmd arguments are passed from the shell to the process memory ? How the loader loads them and if there are passed with some sort of syscall ? ill be happy if some one can explain in details or point to a relevant article.

  • 1
    Which OS are you speaking about ?
    – w s
    Oct 28 '15 at 8:11
  • Linux mainly, but windows will be helpful to Oct 28 '15 at 9:14

For windows, the Loader will copy the parameters into the process' address space during process setup. Specifically it happens when the Address Space is initialized

See Stage 3D Step 8 in Windows Internals:

  1. The user process parameters are written into the process, copied, and fixed up (meaning converted from absolute form to a relative form so that a single memory block is needed).

You can read about system calls called fork and execve including kernel implementation.

User land implementations:

fork and other usage examples

man page of execve including example

Kernel implementation


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.