Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Apr 2010 18:06:16 +1000
From:      "Murray Taylor" <MTaylor@bytecraft.com.au>
To:        <freebsd-questions@freebsd.org>
Subject:   Parent Child SIGPIPE and write  problem
Message-ID:  <E194A4DE220BBE4FAF3AB7C4E7EDA086B4A363@svmailmel.bytecraft.internal>

next in thread | raw e-mail | index | archive | help
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 ###



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E194A4DE220BBE4FAF3AB7C4E7EDA086B4A363>