summaryrefslogtreecommitdiff
path: root/exec/exec.c
blob: c32c637d1af1c2c31b7ff478947412aba9b4508a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#define _POSIX_C_SOURCE 200809L
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#define NOT_RUN		(126)
#define NOT_FOUND	(127)

int main(int argc, char *argv[])
{
	if (argc < 2 || argv == NULL) {
		fprintf(stderr, "%s: missing operands\n", argv[0]);
		return NOT_RUN;
	}

	execvp(argv[1], argv + 1);
	fprintf(stderr, "%s: %s: %s\n", argv[0], argv[1], strerror(errno));
	if (errno == ENOENT) {
		return NOT_FOUND;
	}
	return NOT_RUN;
}