where command line arguments are stored?

前端 未结 4 1908
逝去的感伤
逝去的感伤 2021-01-13 16:29

I have a doubt @ the storage of command line arguments.

myprog.exe -cfgfile myconfig.cfg

commandline args are passed when process gets created so are they

4条回答
  •  日久生厌
    2021-01-13 16:56

    The command line arguments are stored in the application's memory space. Exactly where differs from OS to OS, my guess is it usually goes at the bottom of the heap. The code which puts it there is in the kernel source code for exec on Unix-like OSs, not sure where it would be in Windows (not that you can see the source anyway). The C runtime code (this is where "crt" comes from) takes argv and argc from the stack and then calls main. If you are interested in learning more how an executable starts up in Linux, this paper by Ulrich Drepper (glibc maintainer) may be of value: http://people.redhat.com/drepper/dsohowto.pdf

提交回复
热议问题