summaryrefslogtreecommitdiff
path: root/exec/exec.c
blob: f3ee85e99f99a0598d5fd6446ae0d82059645c31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#define _POSIX_SOURCE
#include <errno.h>
#include <stdio.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;
	}

	execv(argv[1], argv + 1);
	perror(argv[0]);
	if (errno == ENOENT) {
		return NOT_FOUND;
	}
	return NOT_RUN;
}