bug-glibc
[Top][All Lists]
Advanced

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

Query about _cleanup()


From: Martin Grundy
Subject: Query about _cleanup()
Date: Fri, 28 Sep 2001 10:28:19 +0100 (BST)

Hallo...

I apologise in advance because this is not so much as a bug, rather
its a query about glibc...

I am upgrading my Linux system from kernel version 2.0.38 to v2.2.19 and
v2.4,x later, (Slackware v3.4 to Slackware v8). ]I have the source of an
old editor which I like to use (the Rand Editor) and because it is very
old, ('80s) I have always had to fix it at each upgrade.

This time, while everything was ok at v2.0.38 with gcc v2.7.2.3 and libc
v5.4.33, using gcc v2.95.3 and libc (glibc) v2.2.3 the linker found an
Undefined symbol _cleanup().  Searching the source of libc v5.4.33, in
libio/genops.c I found a function _IO_cleanup() with an "alias" (for the
want of a better term) to _cleanup(), ie:

        #ifdef weak_alias
        weak_alias (_IO_flush_all, _cleanup)
        #endif

In glibc v2.2.3, the function _IO_cleanup() was there, as well as the
alias:

        #ifdef weak_alias
        weak_alias (_IO_cleanup, _cleanup)
        #endif

Presumably, weak_alias was not defined when the later library was complied.

All this is very interesting, but I get the feeling that the _IO_...
functions are intended to be internal to the library, and not for use in
"user" code and maybe, are not guaranteed to be present in future releases
of glibc.

My query is, is the above true, and should a better solution be found?

FYI:
I ask myself, "What was the original author's intention in using the
_cleanup() function?"

_cleanup() only occurs once, in code only called when the editor finds
an unrecoverale error.  The section is as follows:

    fflush (stdout);
    _cleanup();
    signal (ABORT_SIG, SIG_DFL); /* set IOT sig back to deflt for abort() */
    abort();

Presumably, the author was trying to ensure that all data in buffers got
flushed before aborting, not just for stdout, and took the easiest route.

There is only one important file possibly in use, and that is the
keystroke file which stores keystrokes during an edit, so that if anything
goes wrong, the edit session can be replayed automatically.  Since the
keystroke file is open on a stdio stream, perhaps it would be better to an
fflush() or even an fclose() on that stream, or even fcloseall(), rather
than use internal library functions.

Thank you for your time.

-- 
Martin Grundy  (M0ADY)  <address@hidden>
16 Mill Rise, Westdene,
Brighton, East Sussex, UK.
BN1 5GD.

phone:  +44 (0)1273 556399



reply via email to

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