vspawn: fix invalid first argument default tip

Wed, 04 Aug 2021 10:34:16 +0200

author
David Demelier <markand@malikania.fr>
date
Wed, 04 Aug 2021 10:34:16 +0200
changeset 2
a5bab86d0573
parent 1
ede8860cd261

vspawn: fix invalid first argument

vspawn.c file | annotate | diff | comparison | revisions
--- a/vspawn.c	Thu Jul 29 16:36:33 2021 +0200
+++ b/vspawn.c	Wed Aug 04 10:34:16 2021 +0200
@@ -141,7 +141,6 @@
 
 	pid_t pid;
 	int pidfd;
-	char *exec = argv[0];
 
 	if ((pid = parsepid()) != -1)
 		die("abort: already running with pid %d\n", (int)pid);
@@ -161,9 +160,7 @@
 		close(pidfd);
 	}
 
-	/* We need to pass executable to first argument too. */
-	*--argv = exec;
-	execv(exec, argv);
+	execv(argv[0], argv);
 	die("abort: %s\n", strerror(errno));
 }
 

mercurial