[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] too many FOO_exit_failure variables
From: |
Bruno Haible |
Subject: |
Re: [Bug-gnulib] too many FOO_exit_failure variables |
Date: |
Fri, 18 Jul 2003 12:53:31 +0200 |
User-agent: |
KMail/1.5 |
Paul Eggert wrote:
> xalloc_exit_failure = 2;
> xmemcoll_exit_failure = 2;
>
> This doesn't scale well as the number of modules grows.
Sure it does. O(N) lines of code for N modules. If it were O(N^2) I'd
agree that it doesn't scale well.
> How about if we have just a single exit_failure variable, so that
> programs worried about fatal-error exit status can set just that
> variable.
How could this accomodate programs which consider xmalloc() failures
fatal - there's no way to continue if memory is tight - but which
want to gracefully recover from xmemcoll() failures?
Right now you can set
xalloc_exit_failure = 2;
xmemcoll_exit_failure = 0;
to achieve this behaviour (and add some fallback code to xmemcoll.c
for this case). With a single exit_failure variable, you can't.
An alternative to such a global *_exit_failure variable per module is
[except for 'xalloc'] to pass the desired error handling behaviour as an
argument. Like this (in the 'pipe' module):
extern pid_t create_pipe_out (const char *progname,
const char *prog_path, char **prog_argv,
const char *prog_stdout, bool null_stderr,
bool exit_on_error,
int fd[1]);
The idea here is that the callee provides the error message but the
caller determines whether error(0, ...) or error(EXIT_FAILURE, ...)
is called.
Bruno
- [Bug-gnulib] too many FOO_exit_failure variables, Paul Eggert, 2003/07/18
- Re: [Bug-gnulib] too many FOO_exit_failure variables,
Bruno Haible <=
- Re: [Bug-gnulib] too many FOO_exit_failure variables, Paul Eggert, 2003/07/18
- Re: [Bug-gnulib] too many FOO_exit_failure variables, Bruno Haible, 2003/07/18
- Re: [Bug-gnulib] too many FOO_exit_failure variables, Paul Eggert, 2003/07/18
- Re: [Bug-gnulib] too many FOO_exit_failure variables, Jim Meyering, 2003/07/19
- Re: [Bug-gnulib] too many FOO_exit_failure variables, Bruno Haible, 2003/07/20
- Re: [Bug-gnulib] too many FOO_exit_failure variables, Jim Meyering, 2003/07/20
Re: [Bug-gnulib] too many FOO_exit_failure variables, Paul Eggert, 2003/07/22