Return-Path: Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: (qmail 73131 invoked from network); 10 Mar 2011 14:11:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Mar 2011 14:11:31 -0000 Received: (qmail 60761 invoked by uid 500); 10 Mar 2011 14:11:29 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 60732 invoked by uid 500); 10 Mar 2011 14:11:29 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 60699 invoked by uid 99); 10 Mar 2011 14:11:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Mar 2011 14:11:29 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ruj.sabya@gmail.com designates 209.85.216.170 as permitted sender) Received: from [209.85.216.170] (HELO mail-qy0-f170.google.com) (209.85.216.170) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Mar 2011 14:11:22 +0000 Received: by qyk32 with SMTP id 32so4950365qyk.15 for ; Thu, 10 Mar 2011 06:11:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=S1foLCnD6l2nFuEERuvKpO1xfj2+1gyRz8aIb0XyQ6c=; b=QSIxwoC7bupGsBu4gnVgOmsbaL60KznkpH3Dkycv8viPNpIzui6C5QB2Z7Yr9hVwkt La+D3tIbAfEs0EL5/FxFH9lVQqh2TQBMJsO75Jq8zpu/k7xIUbPKHVjdcskEUWNW2gh0 0G8eFd+urfkJqVNhAqe5Ja3+tCI4jRVCzUIpk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=KeEmf9uLxCfflZ1cEunorFdo63vSqXCHNQLGcvZdkjFEPVsW2DYNcFubCvXTfV9/Ab FWFDDsQ9ViUPFBOtzBNbe4RoaN3qgXW/WGosUYlJd+XEZuyugyQc0uKvXiz56YkflWHM s4GUY1vOOUd6/+GPrn6KN6YxTVJPTlUAZlISs= Received: by 10.229.8.212 with SMTP id i20mr6457883qci.22.1299766260916; Thu, 10 Mar 2011 06:11:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.30.10 with HTTP; Thu, 10 Mar 2011 06:10:40 -0800 (PST) In-Reply-To: References: From: Sabyasachi Ruj Date: Thu, 10 Mar 2011 19:40:40 +0530 Message-ID: Subject: Re: Strange behavior if I am declaring a struct String_vector variable To: user@zookeeper.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Oops. I forgot the NULL pointer at the end of argv. My mistake! On 10 March 2011 18:47, Sabyasachi Ruj wrote: > I have two programs "trysample.cpp" and "sample.cpp". trysample.cpp > calls execv to invoke "sample", that is, compiled output of "sample.cpp". > > sample.cpp simply prints the command line arguments passed to it. > > The strange thing is if I am declaring a "struct String_vector" > variable in "trysample.cpp", the arguments received by sample.cpp > becomes wrong. If I am passing 3 arguments, it is showing us 5 > arguments have been passed. But if I just comment the "struct > String_vector s;" part, it works fine! > > Any idea? > > I am giving code for both programs: > > sample.cpp > =3D=3D=3D=3D=3D=3D=3D=3D=3D > #include > #include > #include > > int main(int argc, char *argv[]) > { > =A0printf ("Number of arugments received: %d\n", argc); > =A0for (int i =3D 0; i < argc; i++) { > =A0 =A0printf("%s\n", argv[i]); > =A0} > } > > > trysample.cpp > =3D=3D=3D=3D=3D=3D=3D=3D=3D > #include > #include > #include > #include "zookeeper.h" > > > int main(int argc, char *argv[]) > { > =A0struct String_vector s; > =A0int pid =3D fork(); > =A0if (pid =3D=3D 0) { > =A0 =A0char * argv[] =3D > {"/var/www/vhosts/apps.w/subdomains/sr.c/httpdocs/c/zookeeper/tests/sampl= e", > "aaa", "ddd"}; > =A0 =A0execv("/var/www/vhosts/apps.w/subdomains/sr.c/httpdocs/c/zookeeper= /tests/sample", > argv); > =A0 =A0printf("returned error! %d\n", errno); > =A0} > } > > > > > -- > Sabyasachi > --=20 Sabyasachi