1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| void exec_or_die(int *flag, char **path, char **tab, char **env)
{
char *bin;
int j;
int status;
pid_t pid;
static int co = 0;
void (*point)(pid_t);
point = &check_process;
bin = malloc(sizeof(*bin) * (my_strlen(path[co]) + (*tab == NULL ? 0 : my_strlen(tab[0])) + 2));
bin = my_strcat(path[co], tab[0], bin);
if (path[co + 1] == 0)
co = 0;
if ((j = access(bin, F_OK)) == 0)
if ((j = access(bin, X_OK)) == 0)
{
*flag = 1;
pid = fork();
signal(SIGINT, (*point)(pid))(0);
if (pid > 0)
wait(&status);
else if (pid == 0)
execve(bin, tab, env);
}
++co;
free(bin);
} |