[Asterisk-Users] System called seems forked up

2004-02-21 Thread Bill Michaelson




Attempting to correct the problem about which I earlier posted - wherein
a system() call which apparently succeeds is perceived to have failed by
the * process, I changed code in app_system.c so that it would be more discerning...

 res = system((char
*)data);
 /*
 if (res  0) {
 ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data);
 res = -1;
 } else if (res == 127) {
 ast_log(LOG_WARNING, "Unable to execute '%s'\n", (char *)data);
 res = -1;
 */
 if (res == -1) {
 ast_log(LOG_WARNING, "Fork failed for '%s'\n", (char *)data);
 res = -1;
 } else if (WEXITSTATUS(res) != 0) {
 ast_log(LOG_WARNING, "Error completion for '%s'\n", (char
*)data);
 res = -1;

It is now indeed more discerning, but it has reported Fork failed. But the
fork most certainly has not failed! The shell command invoked has run, and
what's more, completed successfully, producing the expected files.

Referring to the system(2) man page (Red Hat 9, stock)...

RETURN VALUE
 The value returned is -1 on error (e.g. fork failed), and the return
 status of the command otherwise. This latter return status is in
the
 format specified in wait(2). Thus, the exit code of the command
will
 be WEXITSTATUS(status). In case /bin/sh could not be executed,
the
 exit status will be that of a command that does exit(127).

...and noting that "fork failed" is only an example of an error, I'm wondering
what *other* condition might cause the -1 return value.

Does anyone have any ideas?





Re: [Asterisk-Users] System called seems forked up

2004-02-21 Thread andrewg
On Sat, Feb 21, 2004 at 09:08:02AM -0500, Bill Michaelson wrote:
 
 Does anyone have any ideas?
 

Can you check the errno? strerror(errno); should give you a string of why  it
failed. (Just be careful not to use other stuff which touches errno after the
fork()

(note, I didn't read over the code, just something that came to mind.)
___
Asterisk-Users mailing list
[EMAIL PROTECTED]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users