delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/05/14/04:54:59

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <op.vcop6qoo1e62zd@merlin.emma.line.org>
References: <AANLkTik_jo0N1YtUTFLzsqAsv5OkkyjCG9epeMq55bWk AT mail DOT gmail DOT com> <op DOT vcop6qoo1e62zd AT merlin DOT emma DOT line DOT org>
Date: Fri, 14 May 2010 16:54:36 +0800
Message-ID: <AANLkTikoAoUAarNLwuIHe6GypKg62rjKR1VPyQYygT17@mail.gmail.com>
Subject: Re: vfork always fail problem
From: Huang Bambo <bambo DOT huang AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

I's the problem of the fork() pass a wrong program path to CreateProcessW.

It shoud pass a GBK code pathname to CreateProcessW but if I set
 LANG=3Den_US.UTF-8, the pathname passed to CreateProcessW is UTF-8, so
CreateProcessW report file not found.


2010/5/14 Matthias Andree <matthias DOT andree AT gmx DOT de>:
> Am 14.05.2010, 06:29 Uhr, schrieb Huang Bambo:
>
>> [Bambo AT bambo-notebook 4.4.4]$ cat tvfork.c
>> #include <sys/types.h>
>> #include <unistd.h>
>> #include <stdio.h>
>>
>> int main(void)
>> {
>> =A0 =A0 =A0 =A0pid_t pid =3D vfork();
>> =A0 =A0 =A0 =A0if ( pid > 0 )
>> =A0 =A0 =A0 =A0{
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("I'm chield.\n");
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_exit(0);
>> =A0 =A0 =A0 =A0}
>> =A0 =A0 =A0 =A0else if ( pid =3D=3D 0 )
>> =A0 =A0 =A0 =A0{
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("I'm parent");
>> =A0 =A0 =A0 =A0}
>
> You've got these swapped. pid =3D=3D 0 means child, > 0 means parent (so =
that it
> directly has the PID of its child and can later call waitpid()).
>
> You later wrote you've issues with the path; does the same happen if you =
use
> "fork" rather than "vfork"? =A0vfork()ed child processes must not do anyt=
hing
> but modify a variable of type pid_t, call _exit() or exec*().
>
> --
> Matthias Andree
>
> --
> Problem reports: =A0 =A0 =A0 http://cygwin.com/problems.html
> FAQ: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 http://cygwin.com/faq/
> Documentation: =A0 =A0 =A0 =A0 http://cygwin.com/docs.html
> Unsubscribe info: =A0 =A0 =A0http://cygwin.com/ml/#unsubscribe-simple
>
>

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019