Nie do końca ponieważ mam taki program:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int n;
if (argc <= 1){
printf("Podaj argument!\n");
return -1;
}
n= atoi(argv[1]);
if (n >=1) {
int i;
for (i=0;i<n;i++){
int pid1=fork();
if (pid1==0){
execlp("echo","echo","-n","a\n",NULL);
else{//parent
int pid2=fork();
if (pid2==0){
waitpid(pid1, NULL, 0);
usleep(5);
printf("b\n");
return 0;
}
else{
int pid3=fork();
if (pid3==0){
waitpid(pid1,NULL, 0);
waitpid(pid2, NULL, 0);
usleep(10);
printf("c\n");
return 0;
}
else{
waitpid(pid1, NULL, 0);
waitpid(pid2, NULL, 0);
waitpid(pid3, NULL, 0);
}
}
}
}
}
return 0;
}
I chałałabym go uruchomic za pomoca komendy $make 3 czyli drukowałby to samo trzy razy a jak bym wpisała $make 2 to by drukował dwa razy to samo. I nie wiem jakiej komendy użyć w Makefile żeby pobierał dowolny parametr do tego programu.