save avant suppression des jumps

This commit is contained in:
Laureηt 2021-04-24 19:53:12 +02:00
parent 6dfbc2f055
commit 13273c5d4f
3 changed files with 26 additions and 4 deletions

BIN
minishell

Binary file not shown.

View file

@ -56,6 +56,11 @@ void handler_sigchld(int sig_num)
printf("[%d] %d done: %s\n", job->id, job->pid, job->cmd); printf("[%d] %d done: %s\n", job->id, job->pid, job->cmd);
supprimer(&jobs, job->pid); supprimer(&jobs, job->pid);
} }
else if (wait_code == 9) // SIGKILL
{
printf("[%d] %d killed: %s\n", job->id, job->pid, job->cmd);
supprimer(&jobs, job->pid);
}
if (prompting) if (prompting)
{ {
@ -170,13 +175,14 @@ int main(int argc, char *argv[])
cell *job; cell *job;
if (cmd->seq[0][1] == NULL) if (cmd->seq[0][1] == NULL)
{ // no id { // no id
fprintf(stderr, "ERROR: fg id error\n"); fprintf(stderr, "ERROR: id missing\n");
continue; continue;
} }
else else
{ // id specified { // id specified
job = trouver_id(&jobs, atoi(cmd->seq[0][1])); job = trouver_id(&jobs, atoi(cmd->seq[0][1]));
} }
//if (job->state == 1) // créer state bidule
kill(job->pid, SIGCONT); kill(job->pid, SIGCONT);
pause(); pause();
continue; continue;
@ -186,7 +192,7 @@ int main(int argc, char *argv[])
cell *job; cell *job;
if (cmd->seq[0][1] == NULL) if (cmd->seq[0][1] == NULL)
{ // no id { // no id
fprintf(stderr, "ERROR: fg id error\n"); fprintf(stderr, "ERROR: id missing\n");
continue; continue;
} }
else else
@ -198,6 +204,22 @@ int main(int argc, char *argv[])
attendre(job->pid); attendre(job->pid);
continue; continue;
} }
else if (!strcmp(cmd->seq[0][0], "stop"))
{ // "stop"
cell *job;
if (cmd->seq[0][1] == NULL)
{ // no id
fprintf(stderr, "ERROR: id missing\n");
continue;
}
else
{ // id specified
job = trouver_id(&jobs, atoi(cmd->seq[0][1]));
}
kill(job->pid, SIGSTOP);
pause();
continue;
}
else if (!strcmp(cmd->seq[0][0], "pid")) else if (!strcmp(cmd->seq[0][0], "pid"))
{ // "pid" { // "pid"
printf("pid=%d\n", getpid()); printf("pid=%d\n", getpid());

View file

@ -1,2 +1,2 @@
sleep 3 sleep 2
printf "\n\n\n\n bonjour \n\n\n\n" printf "\n\n --- bonjour --- \n\n"