repositories
/
TD_IML.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some indentation cleanups on the Mastermind game
[TD_IML.git]
/
TD1
/
part_two
/
exo.c
diff --git
a/TD1/part_two/exo.c
b/TD1/part_two/exo.c
index bb6f3a5e06356a96bb4f316851183edaa404fa6b..2f5e419062f7be8cdbbb37bc8ab14e23916da617 100644
(file)
--- a/
TD1/part_two/exo.c
+++ b/
TD1/part_two/exo.c
@@
-1,11
+1,11
@@
-#include <sys/types.h>
-#include <sys/wait.h>
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
void show_proc_pids() {
pid_t current_pid = getpid();
pid_t parent_pid = getppid();
void show_proc_pids() {
pid_t current_pid = getpid();
pid_t parent_pid = getppid();
@@
-25,7
+25,6
@@
int main() {
exit(EXIT_FAILURE);
};
exit(EXIT_FAILURE);
};
- const char* str_fmt = "[%d] Coucou papa !\n";
pid_t cpid = fork();
if (cpid == -1) {
pid_t cpid = fork();
if (cpid == -1) {
@@
-34,6
+33,7
@@
int main() {
} else if (cpid == 0) {
printf("Fils:\n");
show_proc_pids();
} else if (cpid == 0) {
printf("Fils:\n");
show_proc_pids();
+ const char* str_fmt = "[%d] Coucou papa !\n";
close(pipefd[0]);
write(pipefd[1], str_fmt, strlen(str_fmt));
close(pipefd[1]);
close(pipefd[0]);
write(pipefd[1], str_fmt, strlen(str_fmt));
close(pipefd[1]);
@@
-42,13
+42,13
@@
int main() {
printf("Parent:\n");
show_proc_pids();
close(pipefd[1]);
printf("Parent:\n");
show_proc_pids();
close(pipefd[1]);
- read(pipefd[0], &buf,
strlen(str_fmt
));
+ read(pipefd[0], &buf,
20*sizeof(buf
));
printf(&buf, getpid());
close(pipefd[0]);
wait(NULL);
exit(EXIT_SUCCESS);
}
printf(&buf, getpid());
close(pipefd[0]);
wait(NULL);
exit(EXIT_SUCCESS);
}
-
+
/* unreachable code */
return EXIT_SUCCESS;
}
/* unreachable code */
return EXIT_SUCCESS;
}