Re: Should program exit, When close() failed for O_RDONLY mode

Поиск
Список
Период
Сортировка
От Noah Misch
Тема Re: Should program exit, When close() failed for O_RDONLY mode
Дата
Msg-id 20200503171827.GB360383@rfd.leadboat.com
обсуждение исходный текст
Ответ на Should program exit, When close() failed for O_RDONLY mode  ("Lin, Cuiping" <lincuiping@cn.fujitsu.com>)
Ответы Re: Should program exit, When close() failed for O_RDONLY mode  (Michael Paquier <michael@paquier.xyz>)
Список pgsql-hackers
On Tue, Apr 14, 2020 at 02:32:40AM +0000, Lin, Cuiping wrote:
>  I find that most of the code does not check the return value of close(),  When open a file for reading(O_RDONLY).
> 
>  But I find that it checks the return value of close() in code "src/bin/pg_rewind/copy_fetch.c" When open a file for
reading(O_RDONLY).

I think ignoring the return value is a superior style.  It is less code, and
failure "can't happen."

>  And it will call pg_fatal to cause premature exit. 
> 
>  I think that when closing a read-only file fails, it shouid not exit  the program early.It  should ensure that the
programexecution is completed.
 

I would not say that.  If close() does fail, something is badly wrong in the
program or the system running it.  Though I opt not to check the return value,
if one does check it, exiting is a suitable response.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: design for parallel backup
Следующее
От: Andres Freund
Дата:
Сообщение: Re: design for parallel backup