atexit and return status on 64bit
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > atexit and return status on 64bit




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    atexit and return status on 64bit  
shaanxxx


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-29-07 06:17 PM

I have following peace of code

void autoclose(void)
{

closesystem(); //user function

}

int main()
{

opensystem(); // user function
atexit(autoclose);
return 0;
}

When i run above programme and check the status , i get 144.


Now i modify above code to following code
int main()
{

opensystem(); // user function
closesystem();
return 0;
}

Now i get return status as zero. I am not able to figure what could be
the reason to get different status.
Expected status is zero.

I am getting zero status on solaris 32 and 64bit machin. Even i am
getting the right status on 32bit linux
platform. But on 64bit linux , i Am getting  144. Any comment would be
appreciated.


$ uname -a
Linux redhats.xyz.com 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:56:28 EST
2006 x86_64 x86_64 x86_64 GNU/Linux

redhats: $ g++ -v
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.5/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --enable-shared --enable-threads=posix --
disable-checking --with-system-zlib --enable-__cxa_atexit --disable-
libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)


Thanks,
Shaan.






[ Post a follow-up to this message ]



    Re: atexit and return status on 64bit  
shaanxxx


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-29-07 06:17 PM



On Jan 29, 7:24 pm, "shaanxxx" <shaan...@yahoo.com> wrote:
> I have following peace of code
>
> void autoclose(void)
> {
>
> closesystem(); //user function
>
> }int main()
> {
>
>        opensystem(); // user function
>         atexit(autoclose);
>         return 0;
>
> }When i run above programme and check the status , i get 144.
>
> Now i modify above code to following code
> int main()
> {
>
>        opensystem(); // user function
>        closesystem();
>         return 0;
>
> }Now i get return status as zero. I am not able to figure what could be
> the reason to get different status.
> Expected status is zero.
>
> I am getting zero status on solaris 32 and 64bit machin. Even i am
> getting the right status on 32bit linux
> platform. But on 64bit linux , i Am getting  144. Any comment would be
> appreciated.
>
> $ uname -a
> Linux redhats.xyz.com 2.6.9-34.ELsmp #1 SMP Fri Feb 24 16:56:28 EST
> 2006 x86_64 x86_64 x86_64 GNU/Linux
>
> redhats: $ g++ -v
> Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.5/specs
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
> infodir=/usr/share/info --enable-shared --enable-threads=posix --
> disable-checking --with-system-zlib --enable-__cxa_atexit --disable-
> libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
> Thread model: posix
> gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)
>
> Thanks,
> Shaan.

Is there way to know exit status in atexit handler ?






[ Post a follow-up to this message ]



    Re: atexit and return status on 64bit  
Andrei Voropaev


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-29-07 06:17 PM

On 2007-01-29, shaanxxx <shaanxxx@yahoo.com> wrote:
[...]
> getting the right status on 32bit linux
> platform. But on 64bit linux , i Am getting  144. Any comment would be
> appreciated.

I also have 64-bit linux. I don't see such behaviour. Try to debug it on
assembler level. Maybe that will clarify something. Make sure that the
function really is called when return value was supposed to be 0.


--
Minds, like parachutes, function best when open





[ Post a follow-up to this message ]



    Re: atexit and return status on 64bit  
Paul Pluzhnikov


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-29-07 06:17 PM

"shaanxxx" <shaanxxx@yahoo.com> writes:

> I have following peace of code

Please learn to cross-post instead of multi-posting, look for
answers in comp.unix.internals:
http://groups.google.com/group/comp...3e44
3c8

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.





[ Post a follow-up to this message ]



    Re: atexit and return status on 64bit  
Giorgos Keramidas


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-29-07 06:17 PM

On 29 Jan 2007 07:05:13 -0800, "shaanxxx" <shaanxxx@yahoo.com> wrote:[vbcol=seagreen] 

I don't have a 64-bit Linux system around, but I tried the following
program on FreeBSD/i386, FreeBSD/amd64, Solaris/i386 and Solaris/amd64:

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

static void opensystem(void);
static void closesystem(void);
static void autoclose(void);

static void
autoclose(void)
{
closesystem();
}

int
main(void)
{
opensystem();
if (atexit(autoclose) != 0) {
perror("atexit");
}
return EXIT_SUCCESS;
}

void
opensystem(void)
{
printf("in %s\n", __func__);
}

void
closesystem(void)
{
printf("in %s\n", __func__);
}
------------------------------------------------------------------------

In all the systems mentioned above, the exit code of the program is zero.
I'm not sure why or even *if* Linux/amd64 is different.

Are you sure closesystem() in your implementation doesn't terminate the
program by calling exit(), or a similar function, with a non-zero
program status?

- Giorgos






[ Post a follow-up to this message ]



    Re: atexit and return status on 64bit  
shaanxxx


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-30-07 12:29 PM

On Jan 29, 8:58 pm, Giorgos Keramidas <keram...@ceid.upatras.gr>
wrote:
> On 29 Jan 2007 07:05:13 -0800, "shaanxxx" <shaan...@yahoo.com> wrote:
> 
>
> I don't have a 64-bit Linux system around, but I tried the following
> program on FreeBSD/i386, FreeBSD/amd64, Solaris/i386 and Solaris/amd64:
>
> ------------------------------------------------------------------------
> #include <stdio.h>
> #include <stdlib.h>
>
> static void opensystem(void);
> static void closesystem(void);
> static void autoclose(void);
>
> static void
> autoclose(void)
> {
>     closesystem();
>
> }
>
> int
> main(void)
> {
>     opensystem();
>     if (atexit(autoclose) != 0) {
>         perror("atexit");
>     }
>     return EXIT_SUCCESS;
>
> }
>
> void
> opensystem(void)
> {
>     printf("in %s\n", __func__);
>
> }
>
> void
> closesystem(void)
> {
>     printf("in %s\n", __func__);}
>
> ------------------------------------------------------------------------
>
> In all the systems mentioned above, the exit code of the program is zero.
> I'm not sure why or even *if* Linux/amd64 is different.
>
> Are you sure closesystem() in your implementation doesn't terminate the
> program by calling exit(), or a similar function, with a non-zero
> program status?
No, it doesnt do exit() in sysclose() function.

>
> - Giorgos







[ Post a follow-up to this message ]



    Re: atexit and return status on 64bit  
Giorgos Keramidas


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-30-07 06:18 PM

On 30 Jan 2007 03:16:24 -0800, "shaanxxx" <shaanxxx@yahoo.com> wrote:
> On Jan 29, 8:58 pm, Giorgos Keramidas <keram...@ceid.upatras.gr>
> wrote: 
>
> No, it doesnt do exit() in sysclose() function.

What does it do then?  We can only 'guess' what is going on without more
information.






[ Post a follow-up to this message ]



    Re: atexit and return status on 64bit  
shaanxxx


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-30-07 06:18 PM

On Jan 30, 6:30 pm, Giorgos Keramidas <keram...@ceid.upatras.gr>
wrote:
> On 30 Jan 2007 03:16:24 -0800, "shaanxxx" <shaan...@yahoo.com> wrote:
> 
> 
> 
> 
> 
>
> What does it do then?  We can only 'guess' what is going on without more
> information.

sysclose kills threads(created by sysopen) and detaches from shared
memory and it write somethings on hardDisk (log flush).







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:16 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register