To my understanding is that, in Windows, the command line parameters are saved in the Process Environment Block.
1) How are they stored in Unix-like systems?
2) In what format/structure are they saved there? Does this concept have a common/general name?
In most languages, the command line arguments are already available in something similar to an array.
3) What parses them into that, and when?
(For example in case of a C program on Windows; other languages and platforms are welcome, too.)
4) How is the data in the PEB related to the data in the “array”?
5) What constrains (eg. max. size, ro, etc.), if any, are in effect to command line arguments, what this is dependent on, what stores this information and how (by what) is it put into effect?
6) Does a shell like Bash (with readline) intend to do more than helping a human user enter arguments in a more convenient way? Ie. do shells generally have some more “active” role in handling command line arguments?
7) How are pipes (in command line) related to command line arguments?
8) Any other information worth mentioning on this?
(Of course please correct me if the question has false assumptions or is not correct.)
1) They are stored on the stack, which is prepared by the kernel.
2) There is a copy in the kernel and a copy on the stack in the user space. In user space, it’s a simple array of pointers which all points to null terminated strings. It’s can’t be simpler than this. The kernel’s copy is for information purpose. i.e. used in /proc. It’s truncated if it’s too long (not very sure about this).
3) When you type command in shell, the shell parses it. When you call
system(), libc parses it. When you call execve, you parsed it before calling. In any case, the kernel doesn’t parse it.5) The size of the stack limits it.
ulimit -a7) Pipe and redirection are not part of cmdline arg. The parser deals with this.