X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:date:message-id:subject:from:to :content-type; q=dns; s=default; b=EIRg4hvj+mTIpUeFi9ktCLTkOoNFQ waVjtHq78HIdJ6dVxpxXoRIIfBwhJ+vqFvryTNuD5RW2iiz1J6zs0KQNC1Qilmoa nkgzg1IS3kccQPjkOIR+T25ozJTlpZkV0UM6+5C74pAKo1nUi2YB2h6Rq7VOSElA 52MGGwewtdIHRo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:date:message-id:subject:from:to :content-type; s=default; bh=djLTxybtEuwtar3L3JaggYGGWjU=; b=kcq kNiaKgsNSyR1P27rDse8ud8LB6v0evJego9kqtzl4E8CLsj1UmmG4rb8GQYfs2aF nZYpjVPbp1J7mfiJk40vrUAUWksArSo7G6rAGGAJ6vXY2Rs4URIARAmULqbBBZDI M9T0CgbMR1HJtFZ+C0svQhpE2u217H4wxs8EqClE= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-lb0-f177.google.com MIME-Version: 1.0 X-Received: by 10.112.185.101 with SMTP id fb5mr5838211lbc.12.1424923951978; Wed, 25 Feb 2015 20:12:31 -0800 (PST) Date: Wed, 25 Feb 2015 23:12:31 -0500 Message-ID: Subject: Why does CYGWIN double the backslash in execvp()? From: A L To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 Hello, Here's code that (if BUG is defined) does not work because it looks like Cygwin doubles the backslash in args[2] when that gets passed to CMD. If I add a trailing period (#undef BUG), the preceding backslash does not get doubled, the command runs as it is supposed to. Why there's an additional backslash in the first case? Should not args be passed "as is"? Running under strace confirms the extraneous addition. --- #include #include #define BUG int main() { const char* args[4]; char** xargs; args[0] = "/cygdrive/c/windows/system32/cmd.exe"; args[1] = "/c"; #ifdef BUG args[2] = "DIR C:\\"; #else args[2] = "DIR C:\\."; #endif args[3] = 0; printf("Command = \"%s %s %s\"\n", args[0], args[1], args[2]); xargs = (char**) &args; execvp(args[0], xargs); return 0; } --- Compare: 1834 22106 [main] a 7152 child_info_spawn::worker: pid 7152, prog_arg /cygdrive/c/windows/system32/cmd.exe, cmd line C:\windows\system32\cmd.exe /c "DIR C:\\") 1595 19614 [main] a 4356 child_info_spawn::worker: pid 4356, prog_arg /cygdrive/c/windows/system32/cmd.exe, cmd line C:\windows\system32\cmd.exe /c "DIR C:\.") Maybe I'm doing something wrong, any ideas? Thanks, AL -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple