[rrd-developers] Re: rrdtool libraries segfault with getopt

Markus Baertschi markus at markus.org
Fri Apr 4 19:54:40 MEST 2003


I've done some experimenting and can found, that the rrd_* routines
require that the optind variable is set to zero before calling them.
If you use getopt the optind variable points to the last argument
in your respective argv after the array is processed. Getopt picks
up where it left using this method. As this is standard unix proctice
, I feel that the rrd_* routines should reset optind to zero before 
getopt processing. 
One could argue the user of getopt should reset optind to zero after
each usage of getopt, but I've never seen this done. At the moment 
the rrd_* routines assume that getopt is zero, which breaks them for
any program using getopt itself.

Brian, Peter,

thanks for your input. For now I stick to my workaround. I've had a look
at 1.1 and found that it has no feature I would need and my 1.0 setup
is working.

Regards Markus

On Thu, 3 Apr 2003 23:32:30 +0200 (MEST), Tobias Oetiker wrote:

>Today Markus Baertschi wrote:
>> I'm developping an app in C which is calling rrd_update and rrd_create
>> directly (linking with librrd). So far things are working, but there
>> is a problem if I mix calls to rrd_create and rrd_update. The rrd_update
>> call generates a segfault and my app is dead :-(.
>how about using rrd_cgi.c or rrd_tool.c as an example? see how
>optind gets reset ?
> ______    __   _
>/_  __/_  / /  (_) Oetiker @ ISG.EE, ETZ J97, ETH, CH-8092 Zurich
> / // _ \/ _ \/ /  System Manager, Time Lord, Coder, Designer, Coach
>/_/ \.__/_.__/_/   http://people.ee.ethz.ch/~oetiker   +41(0)1-632-5286

  Markus Baertschi             Phone: ++41 (21) 807 1677
  Bas du Rossé 14b             Fax  : ++41 (21) 807 1678
  CH-1163, Etoy                Email: markus at markus.org
  Switzerland                  Homepage: www.markus.org

Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the rrd-developers mailing list