File tree Expand file tree Collapse file tree 6 files changed +61
-4
lines changed
Expand file tree Collapse file tree 6 files changed +61
-4
lines changed Original file line number Diff line number Diff line change 55#include <unistd.h>
66#include <stdbool.h>
77
8- int main (int argc , char const * argv [] )
8+ void main ()
99{
10- char nom [50 ];
10+ /* char nom[50];
1111 char prenom[50];
1212 int res;
1313 printf("Saisissez votre nom suivi de votre prénom : ");
1414 res = scanf("%49s%49s", nom, prenom);
1515 if (res == 2)
1616 printf("Très bien %s %s\n", prenom, nom);
17- else
17+ else
18+ {
1819 printf("Vous avez fait une erreur lors de la saisie.\n");
20+ }*/
21+
22+ printf ("Bonsoir Nom Prénom\n" );
1923}
Original file line number Diff line number Diff line change 55#include <unistd.h>
66#include <stdbool.h>
77
8- int main (int argc , char const * argv [] )
8+ void main ()
99{
1010 printf ("Très bien\n" );
1111}
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <stdlib.h>
3+ #include <string.h>
4+ #include <fcntl.h>
5+ #include <unistd.h>
6+ #include <stdbool.h>
7+
8+ int main (int argc , char const * argv [])
9+ {
10+ int n ;
11+ if ((n = fork ()) == 0 )
12+ {
13+ // Fils 1
14+ // exécution programme ex5
15+ execve ("./ex5bis" , NULL , NULL );
16+ printf ("\n" );
17+ // on attends on sait jamais
18+ sleep (1 );
19+ exit (0 );
20+ }
21+ else
22+ {
23+ if ((n > 0 ))
24+ {
25+ // père
26+ //printf("Père : Processus père avec PID : %i\n", getpid());
27+
28+ // Création de fils
29+ int n2 ;
30+ if ((n2 = fork ()) == 0 )
31+ {
32+ // Fils 2
33+ // exécution programme ex5
34+ execve ("./ex5" , NULL , NULL );
35+ printf ("\n" );
36+ // on attends on sait jamais
37+ sleep (1 );
38+ exit (0 );
39+ }
40+ else if (n2 < 0 )
41+ {
42+ printf ("Erreur\n" );
43+ return -1 ;
44+ }
45+ }
46+ else
47+ {
48+ // Erreur
49+ printf ("Erreur de PID\n" );
50+ return -1 ;
51+ }
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments