summaryrefslogtreecommitdiff
path: root/src/unistd/execvp.c
blob: 5ad54781ba9d62190e84dd30580d6023a11b64ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "stddef.h"
#include "sys/types.h"
#include <unistd.h>
#include "errno.h"

int execvp(const char *file, char *const argv[])
{
	extern char **environ;
	/* search $PATH for file */
	execve(file, argv, environ);
	if (errno == ENOEXEC) {
		/* stuff /bin/sh in front */
		char sh[] = "/bin/sh";
		return execve(sh, argv, environ);
	}
	return -1;
}
/*
POSIX(1)
*/