Robert Elz wrote, on 28 Jun 2021: > > [email protected] (really Geoff Clare) said: > | The error occurred, and because of it the utility did not do what it is > | supposed to do. > > That's debatable. The outcome was not what was desired, but the utility > did exactly what was required of it, it determined (one assumes for this > purpose, where this fails truly is an error to be reported) the current > working directory and printed it, then exited, with no errors reported to > it.
You are wrong when you say it "printed it". It tried to print it but failed to do so. > You might prefer that it "fflush(stdout); if (ferror(stdout)) ..." but > there's nothing explicit in the standard that says that it has to do that. There's nothing in the standard that requires pwd to be written in C, so any argument based on C functions has no merit. The standard requires that pwd writes to stdout. If it doesn't write to stdout then it hasn't done what it is supposed to do and it absolutely must not exit with zero status in that case. > | If write() fails with EPIPE then yes I would expect pwd to write > | a diagnostic message and exit with non-zero status. > > Are you talking explicitly about pwd, or about utilities that are designed > to write to stdout in general? It applies to every utility for which writing to stdout is something the utility needs to do in order to be considered to have completed successfully. > If in general, then forget it - the users would lynch you (you'd probably > suicide first) if you successfully caused that to happen. No they wouldn't. The only reason to set SIGPIPE to be ignored is because you want EPIPE error conditions to be diagnosed instead of causing the process to terminate. So fixing these bugs is exactly what users want. > | You are talking about pre-POSIX tradition. The rules in POSIX.2 should > have > | put an end to that ancient dodgy behaviour when systems were updated to > | conform to POSIX. > > Do you have some evidence that they did? I said "should have". Obviously that didn't happen, at least for some systems. -- Geoff Clare <[email protected]> The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
