28 lines
546 B
C
28 lines
546 B
C
#include "exec.h"
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
int is_builtin_cmd(char *executable) {
|
|
(void)executable;
|
|
return 0;
|
|
}
|
|
|
|
int execute_cmd(char **args) {
|
|
if (!is_builtin_cmd(args[0])) {
|
|
int pid = fork();
|
|
if (pid == -1)
|
|
return -1;
|
|
|
|
if (pid == 0) {
|
|
// Ce que va exécuter l'enfant
|
|
int status_code = execvp(args[0], args);
|
|
perror("seyshell");
|
|
return status_code;
|
|
} else {
|
|
// Ce que va exécuter le parent
|
|
int status;
|
|
waitpid(pid, &status, WUNTRACED);
|
|
}
|
|
}
|
|
return 1;
|
|
} |