From owner-freebsd-questions@FreeBSD.ORG Fri Apr 30 08:24:14 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 131C81065674 for ; Fri, 30 Apr 2010 08:24:14 +0000 (UTC) (envelope-from MTaylor@bytecraft.com.au) Received: from bcmelmx.bytecraft.au.com (bcmelmx.bytecraft.au.com [203.39.118.2]) by mx1.freebsd.org (Postfix) with ESMTP id 77CD88FC19 for ; Fri, 30 Apr 2010 08:24:13 +0000 (UTC) Received: from svmailmarshal.bytecraft.internal ([10.48.0.3]) by bcmelmx.bytecraft.au.com (8.13.8/8.12.11) with ESMTP id o3U86IJE060273 for ; Fri, 30 Apr 2010 18:06:18 +1000 (EST) (envelope-from MTaylor@bytecraft.com.au) Received: from svmailmel.bytecraft.internal (Not Verified[10.48.0.24]) by svmailmarshal.bytecraft.internal with MailMarshal (v6, 7, 2, 8378) id ; Fri, 30 Apr 2010 18:06:17 +1000 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Fri, 30 Apr 2010 18:06:16 +1000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Parent Child SIGPIPE and write problem Thread-Index: AcroPAJJXRF2+bmPRf22Qcuqk2qm0Q== From: "Murray Taylor" To: Subject: Parent Child SIGPIPE and write problem X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Apr 2010 08:24:14 -0000 I am writing a process that has a parent running as a daemon process that has to spawn an appropriate child to parse whatever the parent has in one of several formats (hence the variety of child parsers) I am getting occasional SIGPIPE errors (and the boring bit is that I have put in code that I think _should_prevent the SIGPIPE occurring any comments or guidance welcome ... parent pseudo code main() { =09daemon =09while(1) =09{ =09 get test data =09 pipe() =09 fork() =09 in Parent =09 read(child->parent pipe) until \n =09 log string to logfile =09 write(parent->child pipe) real data to child for processing =09 close(parent->child pipe) =09 =09 read(child->parent pipe) until EOF for result =09 =09 waitpid(child) =09 get return code =09 in Child =09 set stdin nonblocking so child will inherit =09 execve the correct parser =09} } child pseudo code main() { =09read cmdline params =09write(child->parent pipe) my PID =09read(parent->child pipe) intil EOF =09process through flex/bison parser =09write(child->parent pipe) the result =09return (code) } I am catching SIPPIPE in the parent and logging it, and have a=20 test on the parent write for EPIPE and am doing a go-around twice loop through the write before giving up. Murray Taylor Bytecraft Systems Special Projects Engineer P: +61 3 8710 0600 D: +61 3 9238 4275 F: +61 3 9238 4140 -- =20|_|0|_| "Absence of evidence =20|_|_|0| is not evidence of absence" =20|0|0|0| Carl Sagan --------------------------------------------------------------- The information transmitted in this e-mail is for the exclusive use of the intended addressee and may contain confidential and/or privileged material. Any review, re-transmission, dissemination or other use of it, or the taking of any action in reliance upon this information by persons and/or entities other than the intended recipient is prohibited. If you received this in error, please inform the sender and/or addressee immediately and delete the material.=20 E-mails may not be secure, may contain computer viruses and may be corrupted in transmission. Please carefully check this e-mail (and any attachment) accordingly. No warranties are given and no liability is accepted for any loss or damage caused by such matters. --------------------------------------------------------------- ### This e-mail message has been scanned for Viruses by Bytecraft ###