Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Natalia | 627b541d60 | 12 months ago |
Natalia | 27c672cadb | 12 months ago |
Natalia | 1aea9e839b | 12 months ago |
@ -0,0 +1,24 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i = 6;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
|
||||||
|
if (pid == -1) {
|
||||||
|
printf("Error al crear el proceso hijo");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
if (pid == 0) {
|
||||||
|
i = i - 5;
|
||||||
|
printf("Soy el proceso hijo. Valor: %d\n", i);
|
||||||
|
} else {
|
||||||
|
i = i + 5;
|
||||||
|
printf("Soy el proceso padre. Valor: %d\n", i);
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in new issue