I wanted to start an Program in the Background and it should be could stopped from the first Program. Code vom starter C-Code:
#include<stdio.h>
#include<stdlib.h>
int main() {
char command[50];
int i;
for(i=0; i<10; i++)
{
snprintf(command, sizeof(command), "./test %i &", i);
system(command);
}
printf("FERTIG\n");
}
And here is the code that should be started in this case 10-times: (Later the code should be much bigger and it will be another code, but there will be an while(1) code. So i will need it.)
#include<stdio.h>
int main(int argc, char* argv[])
{
int i;
printf("argc: %i\n", argc);
for(i=0; i < argc; i++)
{
printf("argv[%d]: %s\n", i, argv[i]);
}
printf("FERTIG\n");
while(1)
printf("DAUERSCHLEIFE");
}
I hope someone can help me. And no i cant use any other languages, because im using the raspberry pi, and already familiar with C. I dont want to learn any other languages.
And the Question is, is there a way to stop the while(1)-Loop from the first Program?