[asterisk-users] carefulwrite: write() returned error:Brokenpipe
Danny Nicholas
danny at debsinc.com
Thu Oct 22 14:55:30 CDT 2009
Sorry about the "top post" (OUTLOOK) -
Thanks for the framework. It's easier to learn from a starting point than
scratch. I'm not crazy about writing 1000 lines of C to do 30 lines of
PERL, but if it makes my system fly, so be it.
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Steve Edwards
Sent: Thursday, October 22, 2009 2:45 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] carefulwrite: write() returned
error:Brokenpipe
Un-top-posting...
> On Thu, 22 Oct 2009, Danny Nicholas wrote:
>
>> So this would actually be proper?
>
> [snip]
>
>>> my $envvars = <STDIN>;
> [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Steve
Edwards
>
> I don't "do" Perl, but if that statement reads everything buffered on
> STDIN -- i.e., the AGI environment, then I would guess it would work.
>
> "Proper" would be to read and parse the environment "properly." You could
> make the argument that since you're not going to use anything from the AGI
> environment, why waste the cycles.
>
> I would counter that "best practice" would be to read and parse the
> environment as well as setting up a SIGHUP handler, initializing syslog(),
> setting a STATUS channel variable to FAILURE (and setting it to SUCCESS
> upon successful completion), etc., etc., etc.
On Thu, 22 Oct 2009, Danny Nicholas wrote:
> For my (and any other lazy watchers) benefit, would you post how you would
> do my snippet in C?
I don't think it will do you much good since you don't have my AGI
library, but below is an AGI from a current project that reads a bunch
of stuff from a database and sets a bunch (hundreds) of variables.
I'm a big fan of using an established library so all the funky details
are taken care of for you and you don't get "bit" by changes like you
have. If I had found a C library when I started, I would have used it.
This wasn't written with "publication" in mind but it does show my
"framework" for all my AGIs.
Keep in mind the AGI below executes in less than a second, including the
database accesses.
My apologies to the list for the length :)
//
// Filename: lookup-dnis.c
//
** SNIP **
** SNIP **
// (end of lookup-dnis.c)
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
More information about the asterisk-users
mailing list