| delorie.com/archives/browse.cgi | search |
| 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:date:from:to:subject:message-id:reply-to | |
| :references:mime-version:content-type:in-reply-to; q=dns; s= | |
| default; b=bHVUyZzPVsJ8VIi2pe6i+Qg0icqlqWQg4soXhAsFV1M3upaXDZsHV | |
| Lr9+HzzlvooOJF6HBlr21zwXHM5lK9ZkXsUnKYejZMd2hrCLjX0+KhVZ++zI+yLA | |
| wKA+Hps7BBgqpCo5w//XxwYdI+OpQ8KZVa6yUWWE/GjJ6pBGzPsimM= | |
| 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:date:from:to:subject:message-id:reply-to | |
| :references:mime-version:content-type:in-reply-to; s=default; | |
| bh=lOcjaBuf2AJeiYodchbaimycp5Y=; b=ygcFG5MY4X54pPdfsAemAvrs9Jwb | |
| KvW0iT/QmNsJv5Jcmhuwn5WLuyIBUNtq5JoFFxzSEz5KLbsy6aHydSYPeBWhdfpm | |
| IAG4qknRerpdVQo6/lY9sniTngDgUxOYnkCpTQVrXrMaz1qP70vwGI9VdhdDl43O | |
| CWGX3NryrXwQ1xU= | |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| 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=-6.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 |
| X-HELO: | calimero.vinschen.de |
| Date: | Wed, 15 Jan 2014 17:50:31 +0100 |
| From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: fork() + file descriptor bug in 1.7.27(0.271/5/3) 2013-12-09 11:54 |
| Message-ID: | <20140115165031.GA30785@calimero.vinschen.de> |
| Reply-To: | cygwin AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| References: | <831845 DOT 98759 DOT bm AT smtp116 DOT sbc DOT mail DOT ne1 DOT yahoo DOT com> <52D6B9DC DOT 50903 AT coverity DOT com> |
| MIME-Version: | 1.0 |
| In-Reply-To: | <52D6B9DC.50903@coverity.com> |
| User-Agent: | Mutt/1.5.21 (2010-09-15) |
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Jan 15 11:39, Tom Honermann wrote:
> On 01/13/2014 11:06 AM, tednolan AT bellsouth DOT net wrote:
> ...
> > switch (fork()) {
> >=09=09=09
> > /* error */
> > case -1:
> ...
> > /* child */
> > case 0:
> > fprintf(stderr, "child\n"); fflush(stderr);
> > exit(0);
> > break;
>=20
> The above code is incorrect. It is always wrong to call exit() from
> a forked process that has not yet called one of the exec() family of
> functions. _exit() should be called instead. Best case, calling
> exit() will result in double flushing of any stream buffers held by
> the parent at the time fork() is called (since the buffers will
> (eventually) be flushed by the parent as well as the child (unless
> at least one of the processes aborts or exits with _exit()).
Still, SUSv4 says:
The exit() function shall then flush all open streams with unwritten
buffered data and close all open streams. Finally, the process shall
be terminated [...]
=20
Note that exit only flushes streams with *unwritten* data, but not
streams with *unread* data. So this testcase is still valid and
should work.
Corinna
--=20
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
--6c2NcOVqGQ03X4Wi
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBAgAGBQJS1rxXAAoJEPU2Bp2uRE+gwdgP/1rYabBm/YAabP+DBsPHljMr
xyPUlBwmMsw2sfC04QWUHgy54/ZiMrhkICa71URANWx6G42bEBUnGghk/pwaUUbM
/YioKg/Yn9A1yUQfLw3SdBZB7DO8Gzld9C5hlcYDGHxwU88WugxhO10S4t4ZGq2X
KSRZOjLRBlHI2elVbD1U4SzH1uqnNgUQnvWbLYhry8vjidsaxcNQNnBy8LirLjYs
36GnSdfIKZqQdcZmcvIbSKYn9wcO/iwgqYDUpzcv8KA54uC1nA7GZ7qtabylStSN
7/yO83V+sy37Ck1fKkzyLOtPdJgRD/xHg3hG00VSAJ/Ao0gSCizBHfplGww8I40e
sM2NRKnjcRx6zcZpdU/y5omsmxOqDjn6gfR7auCGwLDhdQWYuk1cVBa5ZAsibGOh
3LwDTUGVveDOuNABRhrKDJX2dm3HuWTXKu9aWUiEN9dR0s16lIkuQwUvRNZlJUWX
VTfDywujeDR4frMaAP0vYY70qFghCj8bx3LFzrGWed/2mES2jgkCoFZF1I0hg2DP
c/paZQ+rknVkQr+axMhVawdz+06sWx/woTbqkvNuu0BZywebPiBsbS25Auox5Jx1
t45mU0lsGp6iFlsPsFYukUCHiymSFDjAyopaw7rxQL6csfWnSe7sJKKjtrQbQRaR
3L496GEDAzrJ/HhIgX+/
=6J3O
-----END PGP SIGNATURE-----
--6c2NcOVqGQ03X4Wi--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |