Return-Path: Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: (qmail 89072 invoked from network); 10 Mar 2011 13:18:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Mar 2011 13:18:42 -0000 Received: (qmail 81596 invoked by uid 500); 10 Mar 2011 13:18:41 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 81568 invoked by uid 500); 10 Mar 2011 13:18:41 -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 81560 invoked by uid 99); 10 Mar 2011 13:18:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Mar 2011 13:18:41 +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 (athena.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 13:18:35 +0000 Received: by qyk32 with SMTP id 32so4906551qyk.15 for ; Thu, 10 Mar 2011 05:18:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=TbLPRjikvSxiHJsTtyNqDXddElghnWK0jqLiPDP1fj8=; b=OOWQ1YznW3Wnev1Iew7QVM9524srDlNHKWoh/PLzf6UlsHaF5b0jomhKB1U6pfdSls LVgqqstUhklmVqA1Na80fDwiUzhMLW6MOtDNz72jdfxZFxQmEnFjLgUT2Z8dyhz+E71g a9/CjC+/iqm6v+QP211MY4avf+KlXh+1gGSAQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=vMIe+vQybkUEJbxXfYdTb7ReVsrFBa6HiCmUl0iOMeSuHmFmRvD8ZndtqE/55Ch31c 9YwsqeEQst7rB9bcI5iNAp65bvM/H5j2QcfwKDZbPGZjujn9NJ/0hEtsBGf5mYjZ3+wH +Abhr86GrUmTBkqvEiN6D9ZcUg9JGfH30eHGQ= Received: by 10.229.36.67 with SMTP id s3mr6392688qcd.60.1299763094166; Thu, 10 Mar 2011 05:18:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.30.10 with HTTP; Thu, 10 Mar 2011 05:17:54 -0800 (PST) From: Sabyasachi Ruj Date: Thu, 10 Mar 2011 18:47:54 +0530 Message-ID: Subject: Strange behavior if I am declaring a struct String_vector variable To: user@zookeeper.apache.org Content-Type: text/plain; charset=ISO-8859-1 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 ========= #include #include #include int main(int argc, char *argv[]) { printf ("Number of arugments received: %d\n", argc); for (int i = 0; i < argc; i++) { printf("%s\n", argv[i]); } } trysample.cpp ========= #include #include #include #include "zookeeper.h" int main(int argc, char *argv[]) { struct String_vector s; int pid = fork(); if (pid == 0) { char * argv[] = {"/var/www/vhosts/apps.w/subdomains/sr.c/httpdocs/c/zookeeper/tests/sample", "aaa", "ddd"}; execv("/var/www/vhosts/apps.w/subdomains/sr.c/httpdocs/c/zookeeper/tests/sample", argv); printf("returned error! %d\n", errno); } } -- Sabyasachi