Check return value of pclose() correctly - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Check return value of pclose() correctly
Date
Msg-id 8cd9fb02-bc26-65f1-a809-b1cb360eef73@enterprisedb.com
Whole thread Raw
Responses Re: Check return value of pclose() correctly  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
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.
Attachment

pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: Support logical replication of DDLs
Next
From: Dilip Kumar
Date:
Subject: Re: heavily contended lwlocks with long wait queues scale badly