You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
422 B
25 lines
422 B
1 year ago
|
#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);
|
||
|
}
|
||
|
|