Check return value of pclose() correctly
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-10-31T08:12:53Z
Lists: pgsql-hackers
Attachments
- v1-0001-Check-return-value-of-pclose-correctly.patch (text/plain) patch v1-0001
I noticed that some (not all) callers didn't check the return value of pclose() or ClosePipeStream() correctly. Either they didn't check it at all or they treated it like the return of fclose(). Here is a patch with fixes. (A failure to run the command issued by popen() is usually reported via the pclose() status, so while you can often get away with not checking fclose() or close(), checking pclose() is more often useful.) There are some places where the return value is apparently intentionally ignored, such as in error recovery paths, or psql ignoring a failure to launch the pager. (The intention can usually be inferred by the kind of error checking attached to the corresponding popen() call.) But there are a few places in psql that I'm suspicious about that I have marked, but need to think about further.
Commits
-
Check return value of pclose() correctly
- 2fe3bdbd691a 16.0 landed