Fixed forking, to prevent LCR to run multiple times
Executing a script caused very weird behaviour, due to forking of LCR.
This commit is contained in:
parent
ca68dbb3a5
commit
8b70a9a5c2
|
@ -2003,10 +2003,8 @@ void EndpointAppPBX::action_execute(void)
|
||||||
if ((pid2 = fork()) == 0) {
|
if ((pid2 = fork()) == 0) {
|
||||||
execve(command, argv, environ);
|
execve(command, argv, environ);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
/* Exit immediately and release the waiting parent. The subprocess falls to init because the parent died */
|
/* Exit immediately and release the waiting parent. The subprocess falls to init because the parent died */
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
trace_header("ACTION execute", DIRECTION_NONE);
|
trace_header("ACTION execute", DIRECTION_NONE);
|
||||||
|
|
15
route.c
15
route.c
|
@ -1902,7 +1902,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset)
|
||||||
struct admin_list *admin;
|
struct admin_list *admin;
|
||||||
time_t now;
|
time_t now;
|
||||||
struct tm *now_tm;
|
struct tm *now_tm;
|
||||||
int pid2;
|
int pid, status;
|
||||||
|
|
||||||
/* reset timeout action */
|
/* reset timeout action */
|
||||||
e_match_to_action = NULL;
|
e_match_to_action = NULL;
|
||||||
|
@ -2086,10 +2086,17 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset)
|
||||||
argv[j++] = isdn_port;
|
argv[j++] = isdn_port;
|
||||||
argv[j++] = e_callerinfo.imsi;
|
argv[j++] = e_callerinfo.imsi;
|
||||||
argv[j++] = NULL; /* check also number of args above */
|
argv[j++] = NULL; /* check also number of args above */
|
||||||
if (fork() == 0) {
|
switch ((pid = fork())) {
|
||||||
if ((pid2 = fork()) == 0) {
|
case 0:
|
||||||
execve(cond->string_value, argv, environ);
|
execve(cond->string_value, argv, environ);
|
||||||
}
|
perror("execve");
|
||||||
|
exit(1);
|
||||||
|
case -1:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
waitpid(pid, &status, 0);
|
||||||
|
if (0 == WEXITSTATUS(status))
|
||||||
|
istrue = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue