Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Fix self upgrade not using the new pkg binary
Bryan Drewery committed 11 years ago
commit 22169ec36c645b83a286d609cb773d4aa84b2c3a
parent c01622414e549aa268ed740e5094eb25e06eaff3
1 file changed +9 -4
modified src/main.c
@@ -431,7 +431,7 @@ export_arg_option (char *arg)
}

static void
-
start_process_worker(void)
+
start_process_worker(char *const *save_argv)
{
	int	ret = EX_OK;
	int	status;
@@ -447,9 +447,12 @@ start_process_worker(void)
	while (1) {
		child_pid = fork();

-
		if (child_pid == 0)
+
		if (child_pid == 0) {
+
			/* Load the new Pkg image */
+
			if (ret == EX_NEEDRESTART)
+
				execvp(getprogname(), save_argv);
			return;
-
		else {
+
		} else {
			if (child_pid == -1)
				err(EX_OSERR, "Failed to fork worker process");

@@ -692,6 +695,8 @@ main(int argc, char **argv)
	if (setenv("POSIXLY_CORRECT", "1",  1) == -1)
		err(EX_SOFTWARE, "setenv() failed");

+
	save_argv = argv;
+

#ifdef HAVE_LIBJAIL
	while ((ch = getopt_long(argc, argv, "+dj:c:C:R:lNvo:", longopts, NULL)) != -1) {
#else
@@ -753,7 +758,7 @@ main(int argc, char **argv)
	optind = 1;

	if (debug == 0 && version == 0)
-
		start_process_worker();
+
		start_process_worker(save_argv);

#ifdef HAVE_ARC4RANDOM
	/* Ensure that random is stirred after a possible fork */