summaryrefslogtreecommitdiffstats
path: root/route.c
diff options
context:
space:
mode:
authorAndreas Eversberg2011-08-10 21:50:45 +0200
committerAndreas Eversberg2011-08-10 21:50:45 +0200
commit8b70a9a5c2071c587ab4016dcbbb8e4bbf6da181 (patch)
tree233c4b8de2cd93d70c725220b76708c9b88bd34f /route.c
parentMake install now works again. (Missing and required macro defintion) (diff)
downloadlcr-8b70a9a5c2071c587ab4016dcbbb8e4bbf6da181.tar.gz
lcr-8b70a9a5c2071c587ab4016dcbbb8e4bbf6da181.tar.xz
lcr-8b70a9a5c2071c587ab4016dcbbb8e4bbf6da181.zip
Fixed forking, to prevent LCR to run multiple times
Executing a script caused very weird behaviour, due to forking of LCR.
Diffstat (limited to 'route.c')
-rw-r--r--route.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/route.c b/route.c
index 8217ff1..c1bf079 100644
--- a/route.c
+++ b/route.c
@@ -1902,7 +1902,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset)
struct admin_list *admin;
time_t now;
struct tm *now_tm;
- int pid2;
+ int pid, status;
/* reset timeout action */
e_match_to_action = NULL;
@@ -2086,10 +2086,17 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset)
argv[j++] = isdn_port;
argv[j++] = e_callerinfo.imsi;
argv[j++] = NULL; /* check also number of args above */
- if (fork() == 0) {
- if ((pid2 = fork()) == 0) {
- execve(cond->string_value, argv, environ);
- }
+ switch ((pid = fork())) {
+ case 0:
+ 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;