From owner-freebsd-hackers Mon Sep 23 6:45:26 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7E6DB37B401 for ; Mon, 23 Sep 2002 06:45:24 -0700 (PDT) Received: from south.nanolink.com (south.nanolink.com [217.75.134.10]) by mx1.FreeBSD.org (Postfix) with SMTP id EA7B943E6E for ; Mon, 23 Sep 2002 06:45:21 -0700 (PDT) (envelope-from roam@ringlet.net) Received: (qmail 83997 invoked by uid 85); 23 Sep 2002 13:54:32 -0000 Received: from sbnd.online.bg (HELO straylight.ringlet.net) (217.75.129.196) by south.nanolink.com with SMTP; 23 Sep 2002 13:54:28 -0000 Received: (qmail 977 invoked by uid 1000); 23 Sep 2002 13:45:26 -0000 Date: Mon, 23 Sep 2002 16:45:26 +0300 From: Peter Pentchev To: Vladimir Terziev Cc: hackers@FreeBSD.org Subject: Re: Problems catching SIGPIPE when writing to a broken stream Message-ID: <20020923134526.GE361@straylight.oblivion.bg> Mail-Followup-To: Vladimir Terziev , hackers@FreeBSD.org References: <20020923163418.216b14ae.vladimirt@rila.bg> <20020923134225.GD361@straylight.oblivion.bg> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0ntfKIWw70PvrIHh" Content-Disposition: inline In-Reply-To: <20020923134225.GD361@straylight.oblivion.bg> User-Agent: Mutt/1.5.1i X-Virus-Scanned: by Nik's Monitoring Daemon (AMaViS perl-11d ) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --0ntfKIWw70PvrIHh Content-Type: text/plain; charset=windows-1251 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 23, 2002 at 04:42:25PM +0300, Peter Pentchev wrote: > On Mon, Sep 23, 2002 at 04:34:18PM +0300, Vladimir Terziev wrote: > >=20 > > Hi hackers, > >=20 > > I'm implementing a programmme, which writes a big amount of data (usin= g write(2)) to a socket. > > When the communication stream has been closed by some reason, during t= he write(2) call, my process receives SIGPIPE. I tryed to catch it with sig= nal(3) and change the behaviour of write(2) call with siginterrupt(3), but = SIGPIPE is still raised to my process and terminates it. > >=20 > > Any help and ideas will be useful! >=20 > You should receive a short write(2) before the SIGPIPE is sent, most > probably a write() which returns -1 and sets errno to, say, ECONNRESET > or something like that. Are you sure *all* your previous writes return > as many bytes as you have tried to write? Hit ':wq' too fast ;) You might want to look into scheduling your write(2) calls only when possible, using either select(2) or poll(2) to check the network socket for writability. G'luck, Peter PS. Wow. 'look writa' returned both 'writable' and 'writability'. 'look writea' returned 'writeable', but not 'writeability'. Strike another one for English grammar ;) --=20 Peter Pentchev roam@ringlet.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 I've heard that this sentence is a rumor. --0ntfKIWw70PvrIHh Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iD8DBQE9jxr27Ri2jRYZRVMRAol/AJ4jNURWIVJuK9UHMDvjTBI3RoirgwCfcPHc ex0WrqOwq9XaZ7VDgp4tRRU= =7GFP -----END PGP SIGNATURE----- --0ntfKIWw70PvrIHh-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message