bleakcabal
03-01-2004, 11:32 AM
I have a program that must call execv with a command entered by the user. If I just call execv the program works but quits after execv, which I think is normal from reading man:execv. So I decided to create a child process like this ( this is in a loop ):
pid = fork();
if (pid == -1) {
printf("\nError");
}
else if (pid == 0) {
wait(NULL);
execv(myStrCat("/bin/", cmd[0]), cmd);
}
The problem is sometimes, and I can't find a pattern for this, the program just goes into an infinite loop where it creates child processes so fast that I can't do anything about it. And these process do not execv anything they just do nothing ( maybe it is because execv executes cmd which must be inputed by the user ). This goes on until :
1: the max number of process that I am able to create under /etc/limits.conf is reached and my machine is unbearably slow.
2: my machine freezes after a while
Which makes debugging kind of hard because it requires many reboots.
Does someone know what could be happening ?
I would appreciate any help anyone could give me !
pid = fork();
if (pid == -1) {
printf("\nError");
}
else if (pid == 0) {
wait(NULL);
execv(myStrCat("/bin/", cmd[0]), cmd);
}
The problem is sometimes, and I can't find a pattern for this, the program just goes into an infinite loop where it creates child processes so fast that I can't do anything about it. And these process do not execv anything they just do nothing ( maybe it is because execv executes cmd which must be inputed by the user ). This goes on until :
1: the max number of process that I am able to create under /etc/limits.conf is reached and my machine is unbearably slow.
2: my machine freezes after a while
Which makes debugging kind of hard because it requires many reboots.
Does someone know what could be happening ?
I would appreciate any help anyone could give me !