From 13273c5d4ff79b7343bf5c8428493b65f0bffb48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Sat, 24 Apr 2021 19:53:12 +0200 Subject: [PATCH] save avant suppression des jumps --- minishell | Bin 33632 -> 33736 bytes minishell.c | 26 ++++++++++++++++++++++++-- test.sh | 4 ++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/minishell b/minishell index b5bc3d75c5c973824720fea8c2ab22c5df1fba38..9ffc9d8bec1702c77a5e3701a10d6245303aefbd 100755 GIT binary patch delta 3425 zcmZWs4Nz3q6@K?E4_OqJ1yNuTmVXdIQHY2|-306-p~k8BQxgm#7%`|AAsvnGDzLHJ zmmQ(kOl@o0G)rc>Vd_+vFAqJHA`knW7(J^n>d+t5= zJKs6?+;i`H^uHvY+AVfuvs0Zp{brk>Kjk(a&GOB~p~kS-SHY$;>$I81a7=QKs7-wN zf^W-h$AMq=J(_>;WQ2cH^R@!!+iy}LE%AaNdn5M5ktmId_B|54#3B|muB80P`Y%u^ z($A+0LaC++LQ5XErzY6LErM{EoTy!2YTCeF9kdvrwtkn}-!h*-`PU+Ypca5+rCe1O zgm`-3BNj+C^_HexmlY|5%!bW8DK*j6HD;3gkjV%6FzNfBrYX`Xblv`Dt5SYmXYU1J2AJy5{5c|6@`5up1=b3Bp%)v_H(3O=1c3Fv1q!I>q3(pL zx4bVz5TazSG>5NBPiC)kXL_dj#p?u?GVk$c(&JqdX>Y2a>INSXt{@L5$y#!tOWL5X zDU{QFx_Ob6vhFRdm=LVC8tB!_-_U}jp zA4H(Q9S`cE#-F$7)_CZ#oX5aU_8%L#y$|Eg1aLM3=l%oy_PS>vA%O^L`MVkME}0hB z_67D=pSzw0pM?)_QS#sy4p)tV+D_;+mi7|(R&Ngk%3%lP0p)O&6j9*$=Tr*yKM1D_`tB*`>@fia3d);-N@qZ zG?LuNtFz)=GYRc^|7bLn!96_)1NChRq|Ttsdw}x(nwJBiAD$#ktNnVtyJadWMHje8 zx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$BXso_lvjD_lslbFNjN7v8Lbw@gOUP=Zc8zSpK4TIy;Il6Xh7M z5e?|KiJjaR^qkeNxY@^N7Y`VN zqY(~u1+tnU7Ux9q2C*LfDX}vr!Lbl|ek}dO$_c9vCEW^IR)p^wEJyB%ft(V_{+*^t z?#wA&V?=>9S`6k*mIm+)jcQ`R(w)y+QHLu1Dx1F+4Ydzc2jC z<9LfZwfs$g?&tnw={at8gh-+7Qc#)u-DMSAR9B7@C6x(cN@bvUrSiqG@3_ntq#&Og zY`$di`Hi?z8P30Qk5u~lMIQ4tf?I@OsO`btQQK=4nbvf%+t1fsw(=0id, 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