This is the mail archive of the
mailing list for the binutils project.
fork call __attribute__((destructor))
- From: Yubin Ruan <ablacktshirt at gmail dot com>
- To: binutils at sourceware dot org
- Date: Sat, 5 Aug 2017 01:01:57 +0800
- Subject: fork call __attribute__((destructor))
- Authentication-results: sourceware.org; auth=none
I used to assumed that a function marked with a
"__attribute__((destructor))" would be called after the .so is
unloaded, typically when the program exit. However, I discover that
when I call "fork()" the destructor is also called.
How could that happen? Is it a bug or something? Am I doing something
wrong? What is the rationale behind that?
And, is there any way to prevent the destructor being called when
somebody call fork()?