Talk:c/io/fopen

Hello,

could you please explain to what ( linux or unix ) group files belong, after they have been a) created b) modified using fopen in a C program?

By this I mean I would like to know the group id of files created or modified using fopen.

[[open(3)] http://linux.die.net/man/3/open ] states for open: The POSIX.1-1990 standard required that the group ID of a newly created file be set to the group ID of its parent directory or to the effective group ID of the creating process. FIPS 151-2 required that implementations provide a way to have the group ID be set to the group ID of the containing directory, but did not prohibit implementations also supporting a way to set the group ID to the effective group ID of the creating process. Conforming applications should not assume which group ID will be used. If it matters, an application can use chown to set the group ID after the file is created, or determine under what conditions the implementation will set the desired group ID.

But what is it like for the c standard defined function fopen ?

Thank you very much.

mrtest


 * File ownership is not part of the C language specification. If you notice, in POSIX, this bit is tagged "CX", meaning "extension to the C standard". --Cubbi (talk) 06:54, 24 October 2014 (PDT)

fopen_s indicates it will warn if the "following erros" are detected. If those are errors, shouldn't the description of fopen indicate so, and what severity? E.g. passing a null pointer to fopen as the path argument - does fopen always return null? is it UB?
 * Yeah, it's UB if the or  parameters are NULL. I dunno if it's really worth mentioning, any invalid pointer leads to undefined behaviour and NULL is one of them. Yhere would have to be specific wording specifying that NULL isn't an invalid pointer for it to be worth bringing up IMO --Ybab321 (talk) 05:41, 25 February 2023 (PST)