Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Apr 2021 12:03:51 +0200
From:      Mateusz Piotrowski <0mp@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: c4207d867c20 - main - fork.2: Add a simple use pattern
Message-ID:  <04cb1d58-a7ca-9ea1-0d69-57251c378794@FreeBSD.org>
In-Reply-To: <YH6lyQHX1fVcB1JX@kib.kiev.ua>
References:  <202104172113.13HLD6UI014137@gitrepo.freebsd.org> <YH6lyQHX1fVcB1JX@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On 20/04/2021 11:58, Konstantin Belousov wrote:
> On Sat, Apr 17, 2021 at 09:13:06PM +0000, Mateusz Piotrowski wrote:
>> URL: https://cgit.FreeBSD.org/src/commit/?id=c4207d867c201a726aa3157e09262f72166c89c4
>>
>> commit c4207d867c201a726aa3157e09262f72166c89c4
>> Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
>> AuthorDate: 2021-04-17 21:10:48 +0000
>> Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
>> CommitDate: 2021-04-17 21:12:06 +0000
>>
>>      fork.2: Add a simple use pattern
>>      
>>      It seems to be a nice idea to show how fork() is usually used in
>>      practice. This may act as a guide to developers who want to quickly
>>      recall how to use the fork() function.
>>      
>>      Reviewed by:    bcr, yuripv
>>      MFC after:      1 week
>>      Differential Revision:  https://reviews.freebsd.org/D27626
>>
> Using printf around fork is not the best idea, and definitely should not
> be provided as a guiding example in the man page.  Using stdio safely around
> fork() requires at least flushing buffers and ensuring that opened FILEs are
> in some consistent state right at fork.
>
> It would work by chance in your example, mostly because you did not used
> anything in stdio before fork, but any further changes would result in
> very puzzling bugs (for beginners, who are the target of this example).

OK, I've opened a revision on Phabricator to address those issues: https://reviews.freebsd.org/D29880




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?04cb1d58-a7ca-9ea1-0d69-57251c378794>