remove stat in initEnv()
Using stat broke initEnv() in a container for some reason.
@@ -1360,7 +1360,7 @@ initEnv(int *attachedFlag)
// clear the flag by default
*attachedFlag = 0;
- if (!g_fn.stat || !g_fn.fopen || !g_fn.fgets || !g_fn.fclose || !g_fn.setenv) {
+ if (!g_fn.fopen || !g_fn.fgets || !g_fn.fclose || !g_fn.setenv) {
//scopeLog("ERROR: missing g_fn's for initEnv()", -1, CFG_LOG_ERROR);
return;
}
@@ -1373,18 +1373,6 @@ initEnv(int *attachedFlag)
return;
}
- // see if it's there
- struct stat statbuf;
- if (g_fn.stat(path, &statbuf) != 0) {
- //if (errno != ENOENT) {
- // scopeLog("ERROR: stat(scope_attach_PID.env) failed", -1, CFG_LOG_ERROR);
- //}
- return;
- }
-
- // the .env file is there so we're attached
- *attachedFlag = 1;
-
// open it
FILE *fd = g_fn.fopen(path, "r");
if (fd == NULL) {
@@ -1392,6 +1380,9 @@ initEnv(int *attachedFlag)
return;
}
+ // the .env file is there so we're attached
+ *attachedFlag = 1;
+
// read "KEY=VALUE\n" lines and add them to the environment
char line[8192];
while (g_fn.fgets(line, sizeof(line), fd)) {
