<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: atexit, getting the exit code in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/atexit-getting-the-exit-code/m-p/3191763#M899167</link>
    <description>Hi James,&lt;BR /&gt;&lt;BR /&gt;echo $?&lt;BR /&gt;&lt;BR /&gt;will give you exit code.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Jeff</description>
    <pubDate>Fri, 13 Feb 2004 10:40:34 GMT</pubDate>
    <dc:creator>Jeff Schussele</dc:creator>
    <dc:date>2004-02-13T10:40:34Z</dc:date>
    <item>
      <title>atexit, getting the exit code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/atexit-getting-the-exit-code/m-p/3191762#M899166</link>
      <description>Is there a way for an atexit handler to get&lt;BR /&gt;the exit code that was in the exit call ?&lt;BR /&gt;&lt;BR /&gt;like exit(5), in my atexit registered &lt;BR /&gt;function, can I determine it was 5 ?&lt;BR /&gt;&lt;BR /&gt;I am using the atexit to register an exit&lt;BR /&gt;handler for a C program, using the aCC compiler, hpux 11.0</description>
      <pubDate>Fri, 13 Feb 2004 10:37:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/atexit-getting-the-exit-code/m-p/3191762#M899166</guid>
      <dc:creator>James Myers</dc:creator>
      <dc:date>2004-02-13T10:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: atexit, getting the exit code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/atexit-getting-the-exit-code/m-p/3191763#M899167</link>
      <description>Hi James,&lt;BR /&gt;&lt;BR /&gt;echo $?&lt;BR /&gt;&lt;BR /&gt;will give you exit code.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Jeff</description>
      <pubDate>Fri, 13 Feb 2004 10:40:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/atexit-getting-the-exit-code/m-p/3191763#M899167</guid>
      <dc:creator>Jeff Schussele</dc:creator>
      <dc:date>2004-02-13T10:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: atexit, getting the exit code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/atexit-getting-the-exit-code/m-p/3191764#M899168</link>
      <description>Because the handlers pushed by atexit expect no arguments there is no direct, portable method to accomplish this. However, you should be able to&lt;BR /&gt;create a wrapper function for exit(), e.g myexit() that first takes the argument and assigns it to a global variable which your handlers could then access.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;int Exit_Status = 1;&lt;BR /&gt;&lt;BR /&gt;/* sample silly function to feed atexit() */&lt;BR /&gt;void myexithandler()&lt;BR /&gt;{&lt;BR /&gt;  (void) fprintf(stderr,"Exit Status = %d\n",Exit_Status);&lt;BR /&gt;   (void) fflush(stderr);&lt;BR /&gt;  return;&lt;BR /&gt;} /* myexithandler */&lt;BR /&gt;&lt;BR /&gt;Now instead of using exit() in your code, use myexit();&lt;BR /&gt;&lt;BR /&gt;void myexit(int status)&lt;BR /&gt;{&lt;BR /&gt;  Exit_Status = status;&lt;BR /&gt;  exit(status);&lt;BR /&gt;  /* NOTREACHED */&lt;BR /&gt;  return;&lt;BR /&gt;} /* myexit */&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Feb 2004 10:52:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/atexit-getting-the-exit-code/m-p/3191764#M899168</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-02-13T10:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: atexit, getting the exit code</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/atexit-getting-the-exit-code/m-p/3191765#M899169</link>
      <description>(there seems to be no nice API for this)&lt;BR /&gt;&lt;BR /&gt;defining something with a name other than exit will not let you catch exit's that are not called form your code.&lt;BR /&gt;&lt;BR /&gt;you can define your own 'void exit(int status) which will override exit() of libc. put your atexit handler code in this exit() routine and at the end a call to '_exit(status)'.  the difference between calling exit() and _exit() is in the exit() man page.&lt;BR /&gt;&lt;BR /&gt;if you run into problems because of other (crt0/dld.sl) atexit handlers not being called, you may need to implement atexit() as well ...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Feb 2004 00:52:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/atexit-getting-the-exit-code/m-p/3191765#M899169</guid>
      <dc:creator>ranganath ramachandra</dc:creator>
      <dc:date>2004-02-16T00:52:56Z</dc:date>
    </item>
  </channel>
</rss>

