|
Home > Archive > Unix Programming > January 2007 > atexit and return status on 64bit
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
atexit and return status on 64bit
|
|
| shaanxxx 2007-01-29, 1: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.
| |
| shaanxxx 2007-01-29, 1: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 ?
| |
| Andrei Voropaev 2007-01-29, 1: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
| |
| Paul Pluzhnikov 2007-01-29, 1: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...74f325ff3e443c8
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
| |
| Giorgos Keramidas 2007-01-29, 1: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
| |
| shaanxxx 2007-01-30, 7:29 am |
| 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
| |
| Giorgos Keramidas 2007-01-30, 1: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.
| |
| shaanxxx 2007-01-30, 1: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).
|
|
|
|
|