Handling argc==0 in the kernel
Handling argc==0 in the kernel
Posted Jan 31, 2022 2:41 UTC (Mon) by marcH (subscriber, #57642)Parent article: Handling argc==0 in the kernel
> The envp array begins immediately after the NULL value that terminates argv.
First, a brief reminder that some standard requires argv[argc] to be NULL would be IMHO very useful. It's not obvious that it does because why would you need a clumsy NULL terminator when you already have a proper argc?
For a while I wondered "Did he mean the \0 byte terminating argv[argc - 1] instead?". The pointer arithmetic and discussion that follows clarifies but it comes after. Also, pointer arithmetic with a mix of pointers and arrays degrading to pointers is... not fun :-)
