Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
If nothing has been read on the socket, maybe the otherside of the socket is closed
Baptiste Daroussin committed 6 years ago
commit 89ca6376e840b9364d1abcfc9cb1ab846ecc5690
parent a701d9d
2 files changed +10 -4
modified libpkg/lua_scripts.c
@@ -226,6 +226,7 @@ pkg_lua_script_run(struct pkg * const pkg, pkg_lua_script type, bool upgrade)
#endif
	struct pollfd pfd;
	int cur_pipe[2];
+
	int r;
	char *line = NULL;
	FILE *f;
	ssize_t linecap = 0;
@@ -311,9 +312,11 @@ pkg_lua_script_run(struct pkg * const pkg, pkg_lua_script type, bool upgrade)
			}
			if (pfd.revents & (POLLERR|POLLHUP))
				break;
-
			if (getline(&line, &linecap, f) > 0) {
+
			r = getline(&line, &linecap, f);
+
			if (r == 0 && feof(f))
+
				break;
+
			if (r > 0)
				pkg_emit_message(line);
-
			}
		}
		fclose(f);

modified libpkg/scripts.c
@@ -63,6 +63,7 @@ pkg_script_run(struct pkg * const pkg, pkg_script type, bool upgrade)
	int ret = EPKG_OK;
	int fd = -1;
	int stdin_pipe[2] = {-1, -1};
+
	int r;
	posix_spawn_file_actions_t action;
	bool use_pipe = 0;
	bool debug = false;
@@ -253,9 +254,11 @@ pkg_script_run(struct pkg * const pkg, pkg_script type, bool upgrade)
				}
				if (pfd.revents & (POLLERR|POLLHUP))
					break;
-
				if (getline(&line, &linecap, f) > 0) {
+
				r = getline(&line, &linecap, f);
+
				if (r == 0 && feof(f))
+
					break;
+
				if (r > 0)
					pkg_emit_message(line);
-
				}
			}
			fclose(f);