mirror of
https://github.com/corda/corda.git
synced 2025-02-05 10:39:13 +00:00
do not call dlclose on the main executable (to avoid crashes)
This commit is contained in:
parent
85abd14137
commit
8f4cb3315a
@ -152,7 +152,7 @@ pathOfExecutable(System* s, const char** retBuf, unsigned* size)
|
||||
#endif
|
||||
}
|
||||
|
||||
const bool Verbose = false;
|
||||
const bool Verbose = true;
|
||||
|
||||
const unsigned Waiting = 1 << 0;
|
||||
const unsigned Notified = 1 << 1;
|
||||
@ -483,9 +483,10 @@ class MySystem: public System {
|
||||
class Library: public System::Library {
|
||||
public:
|
||||
Library(System* s, void* p, const char* name, unsigned nameLength,
|
||||
bool mapName):
|
||||
bool mapName, bool isMain):
|
||||
s(s),
|
||||
p(p),
|
||||
mainExecutable(isMain),
|
||||
name_(name),
|
||||
nameLength(nameLength),
|
||||
mapName_(mapName),
|
||||
@ -517,7 +518,7 @@ class MySystem: public System {
|
||||
fprintf(stderr, "close %p\n", p);
|
||||
}
|
||||
|
||||
dlclose(p);
|
||||
if (!mainExecutable) dlclose(p);
|
||||
|
||||
if (next_) {
|
||||
next_->disposeAll();
|
||||
@ -532,6 +533,7 @@ class MySystem: public System {
|
||||
|
||||
System* s;
|
||||
void* p;
|
||||
bool mainExecutable;
|
||||
const char* name_;
|
||||
unsigned nameLength;
|
||||
bool mapName_;
|
||||
@ -683,6 +685,7 @@ class MySystem: public System {
|
||||
{
|
||||
void* p;
|
||||
bool alreadyAllocated = false;
|
||||
bool isMain = false;
|
||||
unsigned nameLength = (name ? strlen(name) : 0);
|
||||
if (mapName) {
|
||||
unsigned size = nameLength + 3 + sizeof(SO_SUFFIX);
|
||||
@ -693,6 +696,7 @@ class MySystem: public System {
|
||||
if (!name) {
|
||||
pathOfExecutable(this, &name, &nameLength);
|
||||
alreadyAllocated = true;
|
||||
isMain = true;
|
||||
}
|
||||
p = dlopen(name, RTLD_LAZY);
|
||||
}
|
||||
@ -714,7 +718,7 @@ class MySystem: public System {
|
||||
}
|
||||
|
||||
*lib = new (allocate(this, sizeof(Library)))
|
||||
Library(this, p, n, nameLength, mapName);
|
||||
Library(this, p, n, nameLength, mapName, isMain);
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user