Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <getopt.h>
- #include <memory.h>
- #include <ctype.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/wait.h>
- #include <math.h>
- #include <unistd.h>
- #include <stdio.h>
- int main(int argc, char * argv[]){
- int n,c;
- double pot;
- int dr=atoi(argv[optind+1]);
- int pr=atoi(argv[optind]);
- for(n = 0; n < pr; n++){
- switch(fork()){
- case -1:
- perror("tezava pri ustvarjanju novega procesa");
- return -1;
- case 0:
- usleep(1000);
- int pot = dr;
- for(int i = 1; i<=n; i++){
- if(n!=1) {
- pot = pot * dr;
- }
- else pot = 1;
- }
- printf("jaz sem otrok st:%d\n",pot);
- _exit(0);
- }
- }
- for(n = 0; n < pr; n++)
- {
- wait(&c);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement