Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Fail if libnethack is resident before dlopening.
Browse files Browse the repository at this point in the history
This is the issue in #254.
  • Loading branch information
Heinrich Kuttler committed Feb 2, 2022
1 parent ed324b0 commit 0c491f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 10 additions & 2 deletions sys/unix/nledl.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ void
nledl_init(nledl_ctx *nledl, nle_obs *obs, nle_seeds_init_t *seed_init,
nle_settings *settings)
{
nledl->dlhandle = dlopen(nledl->dlpath, RTLD_LAZY);
void *handle = dlopen(nledl->dlpath, RTLD_LAZY | RTLD_NOLOAD);
if (handle) {
dlclose(handle);
fprintf(stderr,
"failure in nledl_init: library %s is already loaded\n",
nledl->dlpath);
exit(EXIT_FAILURE);
}

nledl->dlhandle = dlopen(nledl->dlpath, RTLD_LAZY | RTLD_FIRST);

if (!nledl->dlhandle) {
fprintf(stderr, "%s\n", dlerror());
Expand Down Expand Up @@ -50,7 +59,6 @@ nledl_close(nledl_ctx *nledl)
fprintf(stderr, "Error in dlclose: %s\n", dlerror());
exit(EXIT_FAILURE);
}

dlerror();
}

Expand Down
1 change: 0 additions & 1 deletion sys/unix/rlmain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class ScopedTC
void
play(nledl_ctx *nle, nle_obs *obs, nle_settings *settings)
{
char i;
while (!obs->done) {
for (int r = 0; r < ROWNO; ++r) {
for (int c = 0; c < COLNO - 1; ++c)
Expand Down

0 comments on commit 0c491f9

Please sign in to comment.