diff --git a/minishell b/minishell index b5bc3d7..9ffc9d8 100755 Binary files a/minishell and b/minishell differ diff --git a/minishell.c b/minishell.c index 623c806..fa4e1e2 100644 --- a/minishell.c +++ b/minishell.c @@ -56,6 +56,11 @@ void handler_sigchld(int sig_num) printf("[%d] %d done: %s\n", job->id, job->pid, job->cmd); 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) { @@ -170,13 +175,14 @@ int main(int argc, char *argv[]) cell *job; if (cmd->seq[0][1] == NULL) { // no id - fprintf(stderr, "ERROR: fg id error\n"); + fprintf(stderr, "ERROR: id missing\n"); continue; } else { // id specified job = trouver_id(&jobs, atoi(cmd->seq[0][1])); } + //if (job->state == 1) // créer state bidule kill(job->pid, SIGCONT); pause(); continue; @@ -186,7 +192,7 @@ int main(int argc, char *argv[]) cell *job; if (cmd->seq[0][1] == NULL) { // no id - fprintf(stderr, "ERROR: fg id error\n"); + fprintf(stderr, "ERROR: id missing\n"); continue; } else @@ -198,6 +204,22 @@ int main(int argc, char *argv[]) attendre(job->pid); 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")) { // "pid" printf("pid=%d\n", getpid()); diff --git a/test.sh b/test.sh index fe779ba..1f268a0 100644 --- a/test.sh +++ b/test.sh @@ -1,2 +1,2 @@ -sleep 3 -printf "\n\n\n\n bonjour \n\n\n\n" \ No newline at end of file +sleep 2 +printf "\n\n --- bonjour --- \n\n" \ No newline at end of file