Why atexit is limited to 32 functions?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lak

    Why atexit is limited to 32 functions?

    I am studying the Advanced programming in the unix environment.
    There they says that we can register upto 32 functions with atexit().
    Why that is limited to 32 functions?
    can any one tell the answer?
  • WANG Cong

    #2
    Re: Why atexit is limited to 32 functions?

    On Mon, 25 Feb 2008 20:55:39 -0800,lak wrote:
    I am studying the Advanced programming in the unix environment. There
    they says that we can register upto 32 functions with atexit(). Why that
    is limited to 32 functions?
    can any one tell the answer?
    It's off-topic here. Here we only talk about standard C.
    I think you'd better post your question to comp.unix.progr ammer.

    [OT]
    But I still answer your question here. That's because:

    " POSIX.1-2001 requires that an implementation allow at least ATEXIT_MAX
    (32) such functions to be registered."

    [/OT]

    Comment

    • santosh

      #3
      Re: Why atexit is limited to 32 functions?

      lak wrote:
      I am studying the Advanced programming in the unix environment.
      There they says that we can register upto 32 functions with atexit().
      Why that is limited to 32 functions?
      can any one tell the answer?
      It should support *at* *least* 32 functions to be conforming to the C
      Standard. Most implementations will likely support more.

      Comment

      • santosh

        #4
        Re: Why atexit is limited to 32 functions?

        WANG Cong wrote:
        On Mon, 25 Feb 2008 20:55:39 -0800?lak wrote?
        >
        >I am studying the Advanced programming in the unix environment. There
        >they says that we can register upto 32 functions with atexit(). Why
        >that is limited to 32 functions?
        >can any one tell the answer?
        >
        It's off-topic here. Here we only talk about standard C.
        I think you'd better post your question to comp.unix.progr ammer.
        No necessary. Atexit is also part of ISO C and the limit in question is,
        AFAIK, the same for POSIX and ISO 9899:1999.

        <snip>

        Comment

        • Gerry Ford

          #5
          Re: Why atexit is limited to 32 functions?


          "lak" <lakindia89@gma il.comwrote in message
          news:c4d95577-57b3-46cb-b07f-e7c683d3cf9c@e1 0g2000prf.googl egroups.com...
          >I am studying the Advanced programming in the unix environment.
          There they says that we can register upto 32 functions with atexit().
          Why that is limited to 32 functions?
          can any one tell the answer?
          yeah.

          Unless I'm mistaken, atexit() is when linux emulates windows, wherein a
          bombs out.

          It's a simultaneous miscalculation in both syntaxes.

          --
          Gerry Ford

          "Er hat sich georgiert." Der Spiegel, 2008, sich auf Chimpy Eins komma null
          beziehend.


          Comment

          • user923005

            #6
            Re: Why atexit is limited to 32 functions?

            On Feb 25, 8:55 pm, lak <lakindi...@gma il.comwrote:
            I am studying the Advanced programming in the unix environment.
            There they says that we can register upto 32 functions with atexit().
            Why that is limited to 32 functions?
            It is not limited to 32 functions. It must allow _at least_ 32
            functions. An implementation that supported 1,000,000 functions would
            be conforming.

            From "ISO/IEC 9899:1999 (E)":

            7.20.4.2 The atexit function
            Synopsis
            1 #include <stdlib.h>
            int atexit(void (*func)(void));
            Description
            2 The atexit function registers the function pointed to by func, to be
            called without arguments at normal program termination.
            Environmental limits
            3 The implementation shall support the registration of at least 32
            functions.
            Returns
            4 The atexit function returns zero if the registration succeeds,
            nonzero if it fails.
            Forward references: the exit function (7.20.4.3).

            Comment

            • Keith Thompson

              #7
              Re: Why atexit is limited to 32 functions?

              "Gerry Ford" <invalid@invali d.netwrites:
              "lak" <lakindia89@gma il.comwrote in message
              news:c4d95577-57b3-46cb-b07f-e7c683d3cf9c@e1 0g2000prf.googl egroups.com...
              >>I am studying the Advanced programming in the unix environment.
              >There they says that we can register upto 32 functions with atexit().
              >Why that is limited to 32 functions?
              >can any one tell the answer?
              >
              yeah.
              >
              Unless I'm mistaken, atexit() is when linux emulates windows, wherein a
              bombs out.
              >
              It's a simultaneous miscalculation in both syntaxes.
              Yes, you're mistaken. I'd explain how you're mistaken if I could
              figure out what you're trying to say.

              --
              Keith Thompson (The_Other_Keit h) <kst-u@mib.org>
              Nokia
              "We must do something. This is something. Therefore, we must do this."
              -- Antony Jay and Jonathan Lynn, "Yes Minister"

              Comment

              • user923005

                #8
                Re: Why atexit is limited to 32 functions?

                On Feb 25, 8:55 pm, lak <lakindi...@gma il.comwrote:
                I am studying the Advanced programming in the unix environment.
                There they says that we can register upto 32 functions with atexit().
                Why that is limited to 32 functions?
                can any one tell the answer?
                Run this program and redirect the output to a file, then compile and
                run the output:

                #include <stdio.h>
                #define LIMIT_ATEXIT_TE ST 1024
                int main(void)
                {
                unsigned i;
                puts("#include <stdlib.h>");
                puts("#include <stdio.h>");
                puts("#include <string.h>");

                for (i = 0; i < LIMIT_ATEXIT_TE ST; i++)
                printf("void ae%04u(void){pu ts(\"%04u \");return;}\n" , i, i);

                puts("int main(void) {");

                for (i = 0; i < LIMIT_ATEXIT_TE ST; i++)
                printf("atexit( ae%04u);\n", i);
                puts("return 0;");
                puts("}");
                return 0;
                }

                Comment

                • Gerry Ford

                  #9
                  Re: Why atexit is limited to 32 functions?


                  "Keith Thompson" <kst-u@mib.orgwrote in message
                  news:87ve4crzwj .fsf@kvetch.smo v.org...
                  "Gerry Ford" <invalid@invali d.netwrites:
                  >"lak" <lakindia89@gma il.comwrote in message
                  >news:c4d9557 7-57b3-46cb-b07f-e7c683d3cf9c@e1 0g2000prf.googl egroups.com...
                  >>>I am studying the Advanced programming in the unix environment.
                  >>There they says that we can register upto 32 functions with atexit().
                  >>Why that is limited to 32 functions?
                  >>can any one tell the answer?
                  >>
                  >yeah.
                  >>
                  >Unless I'm mistaken, atexit() is when linux emulates windows, wherein a
                  >bombs out.
                  >>
                  >It's a simultaneous miscalculation in both syntaxes.
                  >
                  Yes, you're mistaken. I'd explain how you're mistaken if I could
                  figure out what you're trying to say.
                  I thought that bombing out was intersyntactic.

                  This, of course, differs with persons who miss with such sincerity.

                  --
                  Gerry Ford

                  "Er hat sich georgiert." Der Spiegel, 2008, sich auf Chimpy Eins komma null
                  beziehend.


                  Comment

                  • William Pursell

                    #10
                    Re: Why atexit is limited to 32 functions?

                    On Feb 26, 6:35 am, user923005 <dcor...@connx. comwrote:
                    On Feb 25, 8:55 pm, lak <lakindi...@gma il.comwrote:
                    >
                    I am studying the Advanced programming in the unix environment.
                    There they says that we can register upto 32 functions with atexit().
                    Why that is limited to 32 functions?
                    can any one tell the answer?
                    >
                    Run this program and redirect the output to a file, then compile and
                    run the output:
                    >
                    #include <stdio.h>
                    #define LIMIT_ATEXIT_TE ST 1024
                    int main(void)
                    {
                    unsigned i;
                    puts("#include <stdlib.h>");
                    puts("#include <stdio.h>");
                    puts("#include <string.h>");
                    >
                    for (i = 0; i < LIMIT_ATEXIT_TE ST; i++)
                    printf("void ae%04u(void){pu ts(\"%04u \");return;}\n" , i, i);
                    >
                    puts("int main(void) {");
                    >
                    for (i = 0; i < LIMIT_ATEXIT_TE ST; i++)
                    printf("atexit( ae%04u);\n", i);
                    puts("return 0;");
                    puts("}");
                    return 0;
                    >
                    }

                    The following should work directly (I say
                    "should", because the limit on my system is
                    (2^31 -1), and the program hasn't finished yet).
                    It's not necessary to have distinct names, since
                    functions can be registered multiple times.

                    #include <stdlib.h>
                    #include <stdio.h>

                    void foo ( void ) {}

                    int
                    main( void )
                    {
                    int i;
                    for( i = 0; ! atexit( foo ); i++ )
                    continue;

                    printf( "Limit is %d\n", i );
                    return 0;
                    }

                    Comment

                    • Keith Thompson

                      #11
                      Re: Why atexit is limited to 32 functions?

                      "Gerry Ford" <invalid@invali d.netwrites:
                      "Keith Thompson" <kst-u@mib.orgwrote in message
                      news:87ve4crzwj .fsf@kvetch.smo v.org...
                      >"Gerry Ford" <invalid@invali d.netwrites:
                      >>"lak" <lakindia89@gma il.comwrote in message
                      >>news:c4d955 77-57b3-46cb-b07f-e7c683d3cf9c@e1 0g2000prf.googl egroups.com...
                      >>>>I am studying the Advanced programming in the unix environment.
                      >>>There they says that we can register upto 32 functions with atexit().
                      >>>Why that is limited to 32 functions?
                      >>>can any one tell the answer?
                      >>>
                      >>yeah.
                      >>>
                      >>Unless I'm mistaken, atexit() is when linux emulates windows, wherein a
                      >>bombs out.
                      >>>
                      >>It's a simultaneous miscalculation in both syntaxes.
                      >>
                      >Yes, you're mistaken. I'd explain how you're mistaken if I could
                      >figure out what you're trying to say.
                      >
                      I thought that bombing out was intersyntactic.
                      >
                      This, of course, differs with persons who miss with such sincerity.
                      Is this supposed to be word salad? (Consult Google if you don't know
                      what "word salad" means.)

                      If you don't start making sense soon, you can expect to be ignored.

                      --
                      Keith Thompson (The_Other_Keit h) <kst-u@mib.org>
                      Nokia
                      "We must do something. This is something. Therefore, we must do this."
                      -- Antony Jay and Jonathan Lynn, "Yes Minister"

                      Comment

                      • Richard Bos

                        #12
                        Re: Why atexit is limited to 32 functions?

                        "Gerry Ford" <invalid@invali d.netwrote:
                        I thought that bombing out was intersyntactic.
                        >
                        This, of course, differs with persons who miss with such sincerity.
                        You are not making sense at all. Are you, perhaps, literally translating
                        idiomatic German into English? Das ist ein Becherspiel.

                        Richard

                        Comment

                        • Ian Collins

                          #13
                          Re: Why atexit is limited to 32 functions?

                          Keith Thompson wrote:
                          >
                          If you don't start making sense soon, you can expect to be ignored.
                          >
                          He has been making something or an arse of himself down the hall in
                          c.l.c++ for a while now.

                          --
                          Ian Collins.

                          Comment

                          • Richard Heathfield

                            #14
                            Re: Why atexit is limited to 32 functions?

                            Keith Thompson said:
                            "Gerry Ford" <invalid@invali d.netwrites:
                            <snip>
                            >>
                            >This, of course, differs with persons who miss with such sincerity.
                            >
                            Is this supposed to be word salad? (Consult Google if you don't know
                            what "word salad" means.)
                            Or consult comp.programmin g, which boasts the world's leading expert.

                            --
                            Richard Heathfield <http://www.cpax.org.uk >
                            Email: -http://www. +rjh@
                            Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                            "Usenet is a strange place" - dmr 29 July 1999

                            Comment

                            • santosh

                              #15
                              Re: Why atexit is limited to 32 functions?

                              Richard Bos wrote:
                              "Gerry Ford" <invalid@invali d.netwrote:
                              >
                              >I thought that bombing out was intersyntactic.
                              >>
                              >This, of course, differs with persons who miss with such sincerity.
                              >
                              You are not making sense at all. Are you, perhaps, literally
                              translating idiomatic German into English? Das ist ein Becherspiel.
                              I think this is just another handle for whoever was previously "werty".

                              Comment

                              Working...