shithub: riscv

ref: 1d07c2a1614a3121a5b9d86f95394caccd61ee56
dir: /sys/src/ape/lib/ap/plan9/execvp.c/

View raw version
#include <unistd.h>
#include <sys/limits.h>
#include <string.h>

extern char **environ;

/*
 * BUG: instead of looking at PATH env variable,
 * just try prepending /bin/ if name fails...
 */

int
execvp(const char *name, const char **argv)
{
	int n;
	char buf[PATH_MAX];

	if((n=execve(name, argv, environ)) < 0){
		strcpy(buf, "/bin/");
		strcpy(buf+5, name);
		n = execve(buf, argv, environ);
	}
	return n;
}