From owner-freebsd-arch Wed Sep 5 3:33:23 2001 Delivered-To: freebsd-arch@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 637E837B408; Wed, 5 Sep 2001 03:33:15 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id UAA27348; Wed, 5 Sep 2001 20:33:02 +1000 Date: Wed, 5 Sep 2001 20:32:35 +1000 (EST) From: Bruce Evans X-X-Sender: To: Terry Lambert Cc: Mikhail Teterin , , , Subject: Re: proctitle progress reporting for dump(8) In-Reply-To: <3B95DB53.13AE8B42@mindspring.com> Message-ID: <20010905201754.U22592-100000@alphplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 5 Sep 2001, Terry Lambert wrote: > Mikhail Teterin wrote: > > > Also, printf() allocates memory for floating point, so if that > > > percentage is a floating point calculation, then you are in double > > > trouble, since you are not allowed to call malloc() in a signal > > > handler. > > > > That's interesting... I can modify it a bit, to round the percentage to > > fit the %d if called as a signal handler. Thanks. Anything else? > > If setproctitle() calls malloc/strsave/etc., it is not safe > to call in a signal handler. Neither is setproctitle() (since it is not in the list of functions that are safe to call in a signal handler), so this is moot. > I'm not saying it does, I'm saying I haven't looked at the > code in libc for the function, and you should, before using > it in a signal handler... setproctitle() directly calls the following functions that are not safe to call in a signal handler (since they are not in the magic list). snprintf, strlen, vsnprintf, sysctl, sysctlbyname I think all of these are safe in practice. It also accesses some variables that are not safe to access in a signal handler (non-auto ones that are not of type "volatile sig_atomic_t" or are accessed by reads). This is unsafe in practice. E.g., concurrent calls to setproctitle() might corrupt the state of the ps_strings variable. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message