X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: cygwin AT cygwin DOT com Subject: Re: vfork always fail problem References: Date: Fri, 14 May 2010 09:38:40 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Matthias Andree" Message-ID: In-Reply-To: User-Agent: Opera Mail/10.53 (Linux) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 Am 14.05.2010, 06:29 Uhr, schrieb Huang Bambo: > [Bambo AT bambo-notebook 4.4.4]$ cat tvfork.c > #include > #include > #include > > int main(void) > { > pid_t pid = vfork(); > if ( pid > 0 ) > { > printf("I'm chield.\n"); > _exit(0); > } > else if ( pid == 0 ) > { > printf("I'm parent"); > } You've got these swapped. pid == 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"? vfork()ed child processes must not do anything but modify a variable of type pid_t, call _exit() or exec*(). -- Matthias Andree -- 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