Thank you Joerg for making it so clear. Yes, the problem is that the
semantics of the fclose call allow the caller to make the above mistake.
And, worst yet, no solution fits all cases.
And, no, you probably do not want:
fclose(&s1)
nor would you want
s1 = fclose(s1) /* because here (void) fclose(s1) would compile and run */
Nor would you want to hand out indexes into a list (because how large
would the list become?).
What I mean to say is if you like any of the above solutions, you can
create your own library implementing it and use it. That's one of the
beauties of the un*x style operating system: Build your own interfaces from
the atoms that exist. But use those atoms carefully, lest you damage yourself
or others.
-- Randy