summaryrefslogtreecommitdiff
path: root/src/loadlib_rel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/loadlib_rel.c')
-rw-r--r--src/loadlib_rel.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/loadlib_rel.c b/src/loadlib_rel.c
index 4c8186d..b3f537b 100644
--- a/src/loadlib_rel.c
+++ b/src/loadlib_rel.c
@@ -141,7 +141,7 @@ static void setprogdir(lua_State *L) {
char progdir[_PATH_MAX + 1];
char *lb;
int nsize = sizeof(progdir)/sizeof(char);
- int n;
+ int n = 0;
#if defined(__CYGWIN__)
char win_buff[_PATH_MAX + 1];
GetModuleFileNameA(NULL, win_buff, nsize);
@@ -186,6 +186,7 @@ static void setprogdir(lua_State *L) {
sprintf(cmd, "lsof -p %d | awk '{if ($5==\"REG\") { print $9 ; exit}}' 2> /dev/null", pid);
fd = popen(cmd, "r");
n = fread(progdir, 1, nsize, fd);
+ pclose(fd);
// remove newline
if (n > 1) progdir[--n] = '\0';