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:message-id:date:from:mime-version:to:subject :content-type:content-transfer-encoding; q=dns; s=default; b=Aib VdrKizbxFTroeZlRyVunq2IfOp6BRQls547Wz6yH/UWcnOmeoU3W6B8aLPDpyOFU axmP+AQRp+0JYR7C81A23MMwYtQAHWeF5lqzeiSaz5MNJCNE0IdFC3qN7R8gEKpT B3Tf+whB2eZH4rbjFZ2FCuctWHsf7CG1n4eHKero= 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:message-id:date:from:mime-version:to:subject :content-type:content-transfer-encoding; s=default; bh=GGMYuw+Lo P0Jo5uHBgIUa3titO0=; b=J763MKZoy2MCfjTxf5GxwGEAP4rIvaKypbR02cfaX MiTSAUT3uRPMkbBVKmDH4Uns864tzduWs8U2AWdFWL2E3R1qrl+rYT2fg8033HBO boa8u2KQZD8iBwZa02mu1g3ilU/5f+iCFp0g7FFn3JIc3x9Ds/FGxRmhI8Kl0OKB Co= 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=-3.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailgw1.uni-kl.de Message-ID: <5242A24E.2030103@mathematik.uni-kl.de> Date: Wed, 25 Sep 2013 10:43:58 +0200 From: Andreas Steenpass User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: fork handler for parent process called in both parent and child process Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Please consider the following testcase: #################### #include #include #include // compile with -lpthread or -pthread void atfork_prepare() { printf("atfork_prepare, pid: %d\n", getpid()); } void atfork_parent() { printf("atfork_parent, pid: %d\n", getpid()); } void atfork_child() { printf("atfork_child, pid: %d\n", getpid()); } void main() { pthread_atfork(atfork_prepare, atfork_parent, atfork_child); pid_t pid = fork(); if (pid == 0) { // child exit(0); } printf("pid of parent process: %d\n", getpid()); printf("pid of child process: %d\n", pid); waitpid(pid, NULL, 0); exit(0); } #################### On Cygwin, I get: $ ./testcase atfork_prepare, pid: 11560 atfork_child, pid: 7744 atfork_parent, pid: 7744 atfork_parent, pid: 11560 pid of parent process: 11560 pid of child process: 7744 atfork_parent() is called in both the parent and the child process, but as far as I understand, it should be called in the parent process only. Best regards, Andreas -- 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