|
|
Log in / Subscribe / Register

Handling argc==0 in the kernel

Handling argc==0 in the kernel

Posted Jan 31, 2022 9:58 UTC (Mon) by larkey (guest, #104463)
In reply to: Handling argc==0 in the kernel by anton
Parent article: Handling argc==0 in the kernel

The POSIX standard says:

> The argument argv is an array of character pointers to null-terminated strings. The application shall ensure that the last member of this array is a null pointer.

There is nothing in POSIX saying "it may be an array, but it also may be NULL". If a pointer may be NULL in any C function, this is explicitly noted. Compare the standard on strtol(3):

> A pointer to the final string shall be stored in the object pointed to by endptr, provided that endptr is not a null pointer.

(https://pubs.opengroup.org/onlinepubs/9699919799/function...).

This is making it explicit that endptr may be NULL. The nptr argument, however, may not be NULL i.e.,

strtol(NULL, NULL, 10);

is *not* allowed. In the same vain, you can't just make argv be NULL.


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds