27 lines
525 B
C
27 lines
525 B
C
#include <unistd.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
if(argc < 2) {
|
|
printf("missing arguments\n");
|
|
return 1;
|
|
}
|
|
|
|
char * args[argc];
|
|
for(int i=1; i < argc; i++)
|
|
args[i-1] = (char *)argv[i];
|
|
|
|
//args have to be null terminated
|
|
args[argc - 1] = (char *) NULL;
|
|
|
|
printf("starting %s\n", argv[1]);
|
|
|
|
if(execv(argv[1], args)) {
|
|
printf("\nfile not found, or error happened\n");
|
|
return 1;
|
|
}
|
|
}
|