shithub: riscv

Download patch

ref: dc501ae1e31dd4c9147f10e0d477ad0967777609
parent: 4e42b9996f05c988f7ab61084b758fb3d1626760
author: cinap_lenrek <[email protected]>
date: Fri Aug 1 23:06:09 EDT 2014

iostats: dont prefix /bin to argv[0] when already absolute or relative path

--- a/sys/src/cmd/iostats.c
+++ b/sys/src/cmd/iostats.c
@@ -316,8 +316,9 @@
 		open("/fd/2", OWRITE);
 		if(chdir(buf) < 0)
 			sysfatal("chdir");
-		exec(argv[0], argv);
-		exec(smprint("/bin/%s", argv[0]), argv);
+		exec(*argv, argv);
+		if(**argv != '/' && strncmp(*argv, "./", 2) != 0 && strncmp(*argv, "../", 3) != 0)
+			exec(smprint("/bin/%s", *argv), argv);
 		sysfatal("exec: %r");
 	default:
 		close(pfd[0]);