Hello all.
We record calls with Monitor (caller and callee separately) then run a script to combine two ‘sides’ in a one file. (there was such a need, tha’ts why we started doing it instead of MixMonitor)
So, we use ‘Monitor’ with ‘m’ option.
https://wiki.asterisk.org/wiki/display/AST/Application_Monitor
Sometimes I see a warning saying that running a script failed.
I can not understand why it happens from time to time. But in fact, the most of conversations are processed well.
http://doxygen.asterisk.org/trunk/d5/d60/monitor_8h.html here I found (with Ctrl-F in browser) ‘Execute of’, but as I’m not a programmer, it’s not obvious to me what happens.
There is not a lot of information to go on, but maybe this will help. That warning is only logged when ast_safe_system returns ‘-1’. From res_monitor.c:
if (ast_safe_system(tmp) == -1)
ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
ast_safe_system can be found in asterisk.c. Basically this function forks and executes a system call. So how can this function return ‘-1’? For starters if it fails to fork the call then ‘-1’ returns. However if it did fork and returned a successful process id then the following is what you would be interested in with regards to failure (a snippet from ast_safe_system):
for (;;) {
res = waitpid(pid, &status, 0);
if (res > -1) {
res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
break;
} else if (errno != EINTR)
break;
}
edit silly keyboard shortcuts. I didn’t finish before I accidentally posted.
Check out the docs on for waitpid. Specifically what is returned and why. This seems to point to maybe a problem in your script? Maybe it exits early due to an error? Check your script for return codes or exit points due to failures.
2 Likes
Another reason it isn’t a failed fork, is that there is an additional error message produced when that happens.
Thank you for the replies.