help-bash
[Top][All Lists]
Advanced

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

[Readline] controlling out-of-memory behavior


From: John Scott
Subject: [Readline] controlling out-of-memory behavior
Date: Mon, 21 Nov 2022 07:43:59 +0000

Hi,

Apologies, I couldn't find a more appropriate mailing list for Readline
help.

I think Readline is an excellent library, but I would like to have
control over the behavior when it fails to allocate memory for the line.
If I recall correctly, right now it aborts the process.

Is there a way to do this? Any suggestions would be appreciated. What
would be wonderful is if there were a way to change the memory allocator
function called by readline so that I could, for example, make a
malloc() wrapper that calls longjmp() on failure. This could also be
useful for supporting, e.g. shared memory by allocating memory with
mmap(NULL, z, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_SHARED, -1, 0);

One thing I considered is making my own rl_extend_line_buffer() function
and making sure it gets loaded instead of Readline's. But this might
rely on non-portable details of how this function works (does the
default implementation do more than a simple realloc?), and if I want to
free all Readline memory on failure I'll need to map the dynamic
allocation functions as well (which will be error-prone if Readline uses
any that I miss, say because they're non-standard).

Thanks all!





reply via email to

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