Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Dietr1ch
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dietr1ch/78ef64eb93ef840262b5 to your computer and use it in GitHub Desktop.
Save Dietr1ch/78ef64eb93ef840262b5 to your computer and use it in GitHub Desktop.
IIC2333: 0 - forks
#include <stdio.h>
#include <unistd.h>
// Output posible para "./programName banner dame ramos"
/**
1234: Creando 3 subprocesos...
4444: ramos
5555: banner
6666: dame
1234: (=
*/
int main(int N, char* args) {
int i = 0;
printf("%d: Creando %d subprocesos...\n", getpid(), N-1);
/**
* TODO: Crear N-1 subprocesos usando fork().
* Cada uno debería imprimir un argumento (i=1..N)
*/
// hijo i:
printf("%d: %s\n", getpid(), args[i]);
// proceso padre
printf("%d: (=\n", getpid());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment