bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: error and program_name


From: Eric Blake
Subject: Re: error and program_name
Date: Wed, 22 Dec 2010 15:30:57 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 12/22/2010 03:19 PM, Jim Meyering wrote:
> Bruno Haible wrote:
> 
>> Ping? No one wants to solve this? It's a critical issue for libposix.
>>
>> Eric Blake wrote:
>>> error() is not POSIX.  Maybe the thing to do is figure out what in
>>> libposix is dragging in error(), and work on breaking that dependency.
>>> That way, a package using libposix then makes their own decision of
>>> whether to supplement things with error() and program_name.
>>
>> I replied:
>>> Very good point. The dependency comes from
>>>
>>>   openat     -->  openat-die  -->  error
>>>   fdopendir
>>>
>>> Can you work on breaking this dependency? I mean, for example,
>>> instead of directly calling openat_save_fail() and
>>> openat_restore_fail(), go through a variable that contains two
>>> function pointers, and have openat() and fdopendir() return an error code
>>> if these function pointers are NULL. Like we do with
>>>   argp_program_version_hook
>>>   error_print_progname
>>>   obstack_alloc_failed_handler
>>> See also
>>>   c_stack_action
>>>   install_sigpipe_die_handler
> 
> Hi Bruno,
> 
> Perhaps I don't understand the proposal, but here is my reaction:
> 
> IMHO, those functions must never return in the unusual case for which
> they now call error and then exit.  The failures are too fundamental[0],
> and we cannot require that all callers handle any new error code or
> interpret existing error codes differently, can we?

Perhaps the thing to do would be:

The openat module has a function pointer openat_failed_handler,
defaulting to NULL.  If we get into the situation where we changed
directories but can't return, then call any non-NULL handler, and resort
to calling abort() if the handler returns or if it was NULL.

The openat-die module then populates the openat_failed_handler with a
function that uses error() rather than abort.

That way, posix modules use just openat and don't drag in error(), but
coreutils imports openat-die to get the nicer behavior than an abort()
(that is, no change from current behavior).

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]