- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- atexit() does it have any twin brother?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 01:31 AM
тАО01-12-2010 01:31 AM
atexit() does it have any twin brother?
I have been using atexit() for some time and now there is a need for me for a function that coudl call something for me just before start of
int main() or void main()
Like atexit() does there exist something like atstart()?
What I intend to do with this so called "atstart()" is to call a function which sets some flag.
Now I have access only to libraries and can modify libraries only, I cannot access the file which contains
void main()..
and hence the reason why i need something like this.
Could some1 tell me if something like this exists? :) Could not find anything :(
One more thing.
When main() starts, is there some internal flag or parameter which is set? So that I can access it and use it in the libraries?.
Thanks a Lot
Regards :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 01:59 AM
тАО01-12-2010 01:59 AM
Re: atexit() does it have any twin brother?
I fail to understand the purpose of this function "atstart()".
Why not calling your function inside the main() function, at the very begin of this program?
You can allways pass some arguments to the main() function and that should serve right if you need to do some checking/whatever.
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 02:25 AM
тАО01-12-2010 02:25 AM
Re: atexit() does it have any twin brother?
similar elsewhere. I've never tried it, but
I'd guess that you'd need to write your own
"mainx()" function, which would do your extra
work, and which would then call "main()"
(with the appropriate arguments). And that
you'd need to pass an appropriate "-e epsym"
option to "ld" when you linked the
executable. Or something like that.
man ld
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 02:42 AM
тАО01-12-2010 02:42 AM
Re: atexit() does it have any twin brother?
Thanks for reply :)
1)
The reason i need the "atstart()" is because I do not have access to the file containing
the main() function.Am working on an existing product.
I am developing some wrapper library for existing functions and am not allowed to touch the main() file.
2)Since have no access to the main() file, I cannot pass any parameters to main() and get the required value.
Thanks and Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 03:05 AM
тАО01-12-2010 03:05 AM
Re: atexit() does it have any twin brother?
> file.
What is "the main() file"? The existing
executable? An object file? If you are not
linking the thing yourself, then you may have
some real trouble.
> [...] I cannot pass any parameters to
> main() and get the required value.
Not even from the command line? If _you_
call "main()", then don't _you_ specify the
parameters?
Perhaps you should begin again, and explain
your situation more clearly.
> Like atexit() does there exist something
> like atstart()?
Who would call your "atstart()"? The linker
is the thing which sets the entry point for
an executable. (Under the direction of the
C compiler (driver), if that's what you use
to link the executable. The linker is not
born knowing that you want it to be
"main()".)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 04:03 AM
тАО01-12-2010 04:03 AM
Re: atexit() does it have any twin brother?
>atexit() does it have any twin brother?
(You are using the wrong adjective, twin means same.)
C++ has static construction and destruction, done before main and after exit, respectively.
>...void main()
(This is illegal. Only int main is valid.)
>When main() starts, is there some internal flag or parameter which is set?
Not that I know of. Why do you care? If you are running a shlib initializer, you already know how to call something before main.
>Horia: I fail to understand the purpose of this function "atstart()".
This is also called a init function.
>Steven: that you'd need to pass an appropriate "-e epsym" option
Leave well enough alone, -e not for use by ordinary users, especially on Integrity.
>Who would call your "atstart()"?
dld of course. -Wl,+init,function_name
>The linker is the thing which sets the entry point for an executable.
You don't want to change the entry point, which must be in libc.
>The linker is not born knowing that you want it to be main.
But libc knows that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 05:19 AM
тАО01-12-2010 05:19 AM
Re: atexit() does it have any twin brother?
Are you trying to use some functions that you can acces from some executable file (the one that have the main() function that you are talking about), and those functions must be called by you in some controlled environment that you must set or what?
Best regards,
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 08:54 AM
тАО01-12-2010 08:54 AM
Re: atexit() does it have any twin brother?
> means same.)
You are using the wrong definition of "twin",
which doesn't mean "same".
http://en.wikipedia.org/wiki/Twin
> [...] -Wl,+init,function_name
That looks potentially useful, however.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 01:20 PM
тАО01-12-2010 01:20 PM
Re: atexit() does it have any twin brother?
That said, I trust Dennis in this space. If you feel that you are stuck you might want to give a very specific problem to solve. There is always another way...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 02:03 PM
тАО01-12-2010 02:03 PM
Re: atexit() does it have any twin brother?
rightmost-shlib, next ... executable ... main
>Steven: You are using the wrong definition of "twin", which doesn't mean "same".
http://en.wikipedia.org/wiki/Twin
It doesn't help you aren't using a dictionary or one that doesn't discuss other that meaning #1. :-)
Better definitions are:
http://en.wiktionary.org/wiki/twin
(#2)
http://www.yourdictionary.com/twin
1b: being one of a pair of such things; being a counterpart
(Saying evil twin may be better. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2010 02:35 PM
тАО01-12-2010 02:35 PM
Re: atexit() does it have any twin brother?
I didn't think that you'd need more help than
that. And, apparently, I was right.
> [...] twins can be radically different.
Yup. Matching DNA does not mean "identical".
(I have a friend with a pair of daughters
which appear very similar -- to a casual
observer. And their divergence seems to grow
as they do.)