Bonsoir, dans le cadre d'un projet d'implémentation d'un mini shell, je dois écrire un programme en c qui exécute une commande en arrière plan.
J'ai écrit quelque chose mais ça n'a pas le résultat escompté.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
29
30 int execute_commande_BG(Expression *e){ pid_t pid = 0; int status = 0; struct sigaction action; action.sa_flags = 0; action.sa_handler = SIG_DFL; sigemptyset(&action.sa_mask); switch(pid){ case (pid_t) -1: erreur_creation_processus(); break; case (pid_t) 0: sigaction(SIGINT, &action, NULL); execlp("bg", "bg", "getpid()", NULL); status = evaluer_expr(e->gauche); exit(0); break; default: kill(pid, SIGINT); elimination_zombie(pid, &status); break; } return status; }
Partager