mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Check return value of pclose() correctly
Some 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(). The correct way is to first check whether the return value is -1, and then report errno, and then check the return value like a result from system(), for which we already have wait_result_to_str() to make it simpler. To make this more compact, expand wait_result_to_str() to also handle -1 explicitly. Reviewed-by: Ankit Kumar Pandey <itsankitkp@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/8cd9fb02-bc26-65f1-a809-b1cb360eef73@enterprisedb.com
This commit is contained in:
@@ -3002,7 +3002,7 @@ runShellCommand(Variables *variables, char *variable, char **argv, int argc)
|
||||
}
|
||||
if (pclose(fp) < 0)
|
||||
{
|
||||
pg_log_error("%s: could not close shell command", argv[0]);
|
||||
pg_log_error("%s: could not run shell command: %m", argv[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user