Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Dec 2007 11:05:39 +0200
From:      Diomidis Spinellis <dds@aueb.gr>
To:        Alfred Perlstein <alfred@FreeBSD.ORG>
Cc:        cvs-src@FreeBSD.ORG, src-committers@FreeBSD.ORG, Diomidis Spinellis <dds@FreeBSD.ORG>, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/bin/mv mv.c
Message-ID:  <47663BE3.6050401@aueb.gr>
In-Reply-To: <20071217062046.GE16982@elvis.mu.org>
References:  <200712161747.lBGHlYk9093518@repoman.freebsd.org> <20071217062046.GE16982@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Alfred Perlstein wrote:
> * Diomidis Spinellis <dds@FreeBSD.org> [071216 09:47] wrote:
>> dds         2007-12-16 17:47:34 UTC
>>
>>   FreeBSD src repository
>>
>>   Modified files:
>>     bin/mv               mv.c 
>>   Log:
>>   Eliminate gcc "variable clobbered" warnings by declaring the variables
>>   living across the vfork as volatile.
>>   
>>   Noted by:       kan
>>   
>>   Revision  Changes    Path
>>   1.48      +2 -1      src/bin/mv/mv.c
> 
> I'm pretty sure that calling warn(3) under vfork() is not allowed
> as it can clobber stdio state.
> 
> To fix this, have the parent catch a return value from the child
> and emit the warning.

This has been there since (at least) 1994, but you're absolutely right. 
  POSIX states: "[...] the behavior is undefined if the process created 
by vfork() either modifies any data other than a variable of type pid_t 
used to store the return value from vfork(), or returns from the 
function in which vfork() was called, or calls any other function before 
successfully calling _exit() or one of the exec family of functions."

I've fixed it in the way you suggested.
-- 
Diomidis Spinellis



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