Commit Diff


commit - 4e80a172c62f9b329f0f876405c8d391358e5e6a
commit + a6ca45d5dd6d6fe622d1a0c2bf771551f13c20dd
blob - c1e3e0b123933e13467cda9be352c1fc603e4fda
blob + 07bd02d8fa88cb026d8119ce8602a088cb502106
--- lib/pack.c
+++ lib/pack.c
@@ -788,7 +788,7 @@ done:
 static const struct got_error *
 pack_stop_privsep_child(struct got_pack *pack)
 {
-	const struct got_error *err = NULL;
+	const struct got_error *err = NULL, *close_err = NULL;
 
 	if (pack->privsep_child == NULL)
 		return NULL;
@@ -796,9 +796,12 @@ pack_stop_privsep_child(struct got_pack *pack)
 	err = got_privsep_send_stop(pack->privsep_child->imsg_fd);
 	if (err)
 		return err;
+	if (close(pack->privsep_child->imsg_fd) == -1)
+		close_err = got_error_from_errno("close");
 	err = got_privsep_wait_for_child(pack->privsep_child->pid);
-	if (close(pack->privsep_child->imsg_fd) == -1 && err == NULL)
-		err = got_error_from_errno("close");
+	if (close_err && err == NULL)
+		err = close_err;
+	imsg_clear(pack->privsep_child->ibuf);
 	free(pack->privsep_child->ibuf);
 	free(pack->privsep_child);
 	pack->privsep_child = NULL;