From owner-freebsd-standards@FreeBSD.ORG Mon Mar 15 11:01:36 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 364DF16A548 for ; Mon, 15 Mar 2004 11:01:36 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1C3FC43D41 for ; Mon, 15 Mar 2004 11:01:36 -0800 (PST) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) i2FJ1abv055983 for ; Mon, 15 Mar 2004 11:01:36 -0800 (PST) (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i2FJ1ZQQ055977 for freebsd-standards@freebsd.org; Mon, 15 Mar 2004 11:01:35 -0800 (PST) (envelope-from owner-bugmaster@freebsd.org) Date: Mon, 15 Mar 2004 11:01:35 -0800 (PST) Message-Id: <200403151901.i2FJ1ZQQ055977@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: freebsd-standards@FreeBSD.org Subject: Current problem reports assigned to you X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Mar 2004 19:01:36 -0000 Current FreeBSD problem reports Critical problems Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- s [2001/01/23] misc/24590 standards timezone function not compatible witn Sin o [2001/03/05] bin/25542 standards /bin/sh: null char in quoted string o [2002/02/25] bin/35307 standards standard include files are not standard c o [2003/03/05] bin/48958 standards The type 'bool' has different sizes for C o [2003/04/21] standards/51209standards [PATCH] add a64l()/l64a/l64a_r functions p [2003/06/05] standards/52972standards /bin/sh arithmetic not POSIX compliant o [2003/07/12] standards/54410standards one-true-awk not POSIX compliant (no exte o [2003/09/15] standards/56906standards Several math(3) functions fail to set err o [2003/12/31] standards/60772standards _Bool and bool should be unsigned o [2004/02/05] standards/62388standards sys/resource.h does not pull in dependenc 10 problems total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- f [1995/01/11] i386/105 standards Distributed libm (msun) has non-standard o [2000/09/24] bin/21519 standards sys/dir.h should be deprecated some more o [2000/12/05] kern/23304 standards POSIX clock_gettime, clock_getres return o [2001/01/16] bin/24390 standards Replacing old dir-symlinks when using /bi s [2001/06/18] kern/28260 standards UIO_MAXIOV needs to be made public o [2001/11/20] standards/32126standards getopt(3) not Unix-98 conformant s [2002/03/18] standards/36076standards Implementation of POSIX fuser command o [2002/06/13] standards/39256standards [v]snprintf aren't POSIX-conformant for s o [2002/07/09] misc/40378 standards stdlib.h gives needless warnings with -an p [2002/08/12] standards/41576standards POSIX compliance of ln(1) o [2002/10/23] standards/44425standards getcwd() succeeds even if current dir has o [2002/12/09] standards/46119standards Priority problems for SCHED_OTHER using p o [2002/12/23] standards/46504standards Warnings in headers o [2003/06/22] standards/53613standards FreeBSD doesn't define EPROTO o [2003/06/24] bin/53682 standards [PATCH] add fuser(1) utitity o [2003/07/24] standards/54809standards pcvt deficits o [2003/07/24] standards/54833standards more pcvt deficits o [2003/07/25] standards/54839standards pcvt deficits o [2003/07/31] standards/55112standards glob.h, glob_t's gl_pathc should be "size o [2003/09/04] standards/56476standards cd9660 unicode support simple hack o [2003/09/27] standards/57295standards [patch] make does not include cmd line va o [2003/10/12] standards/57911standards fnmatch ("[[:alpha:]]","x", FNM_PATHNAME) o [2003/10/29] standards/58676standards grantpt(3) alters storage used by ptsname o [2003/11/29] standards/59797standards Implement C99's round[f]() math fucntions p [2003/12/26] standards/60597standards FreeBSD's /usr/include lacks of cpio.h s [2004/02/14] standards/62858standards malloc(0) not C99 compliant p [2004/02/21] standards/63173standards Patch to add getopt_long_only(3) to libc o [2004/02/25] standards/63371standards [patch] isblank() not in C99/SUSv3 namesp o [2004/03/12] standards/64173standards C99 requires some macros to be c 29 problems total. From owner-freebsd-standards@FreeBSD.ORG Thu Mar 18 14:33:31 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E65C816A4CE for ; Thu, 18 Mar 2004 14:33:30 -0800 (PST) Received: from STVAVAPPL1.BHMSTV (unknown [207.203.42.3]) by mx1.FreeBSD.org (Postfix) with SMTP id 7ED0943D3F for ; Thu, 18 Mar 2004 14:33:30 -0800 (PST) (envelope-from archie@dellroad.org) Received: from unknown(10.104.180.64) by STVAVAPPL1.BHMSTV via csmap id 0a4304da_792b_11d8_897d_00304811e8c8_25077; Thu, 18 Mar 2004 16:24:37 -0600 (CST) Received: from arch20m.dellroad.org (localhost [127.0.0.1]) i2IMXPCm002725 for ; Thu, 18 Mar 2004 16:33:25 -0600 (CST) (envelope-from archie@arch20m.dellroad.org) Received: (from archie@localhost) by arch20m.dellroad.org (8.12.9p2/8.12.9/Submit) id i2IMXPuJ002724 for freebsd-standards@freebsd.org; Thu, 18 Mar 2004 16:33:25 -0600 (CST) (envelope-from archie) From: Archie Cobbs Message-Id: <200403182233.i2IMXPuJ002724@arch20m.dellroad.org> To: freebsd-standards@freebsd.org Date: Thu, 18 Mar 2004 16:33:25 -0600 (CST) X-Mailer: ELM [version 2.4ME+ PL99b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Subject: _BSD_SOURCE vs. __BSD_VISIBLE X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Mar 2004 22:33:31 -0000 Hi, Apologies if this is an old question, searching the archives didn't yeild any answers. All I'm trying to do is write some portable code :-) Here "portable" simply means that it compiles on both FreeBSD and Linux. In order to get the various functions I need I have to set a bunch of flags. On Linux, these flags do the trick (taken from configure.in): AC_DEFINE(_XOPEN_SOURCE, 600, XOpen functions) AC_DEFINE(_GNU_SOURCE, 1, GNU functions) AC_DEFINE(_BSD_SOURCE, 1, BSD functions) AC_DEFINE(_ISOC99_SOURCE, 1, ISO C99 functions) AC_DEFINE(_POSIX_VERSION, 200112, POSIX version) AC_DEFINE(_POSIX_C_SOURCE, 200112, POSIX functions) On FreeBSD, _BSD_SOURCE is not recognized, but _POSIX_C_SOURCE is and it actually causes the BSD functions to be hidden. So I have to manually add __BSD_VISIBLE to get them on FreeBSD. Q1: Why does Linux require _BSD_SOURCE but FreeBSD requires __BSD_VISIBLE? Q2: Is there some standard for these flags documented somewhere? Q3: What is the right and portable set of flags to use? Any enlightenment is greatly appreciated. Thanks, -Archie P.S. Please CC: me as I'm not on this list. __________________________________________________________________________ Archie Cobbs * CTO, Awarix * http://www.awarix.com From owner-freebsd-standards@FreeBSD.ORG Thu Mar 18 15:07:10 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 345C916A4CE for ; Thu, 18 Mar 2004 15:07:10 -0800 (PST) Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [128.30.28.20]) by mx1.FreeBSD.org (Postfix) with ESMTP id E490943D1D for ; Thu, 18 Mar 2004 15:07:09 -0800 (PST) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: from khavrinen.lcs.mit.edu (localhost [IPv6:::1]) by khavrinen.lcs.mit.edu (8.12.9/8.12.9) with ESMTP id i2IN74tx029019 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK CN=khavrinen.lcs.mit.edu issuer=SSL+20Client+20CA); Thu, 18 Mar 2004 18:07:05 -0500 (EST) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.12.9/8.12.9/Submit) id i2IN7403029016; Thu, 18 Mar 2004 18:07:04 -0500 (EST) (envelope-from wollman) Date: Thu, 18 Mar 2004 18:07:04 -0500 (EST) From: Garrett Wollman Message-Id: <200403182307.i2IN7403029016@khavrinen.lcs.mit.edu> To: Archie Cobbs In-Reply-To: <200403182233.i2IMXPuJ002724@arch20m.dellroad.org> References: <200403182233.i2IMXPuJ002724@arch20m.dellroad.org> X-Spam-Score: -19.8 () IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES X-Scanned-By: MIMEDefang 2.37 cc: freebsd-standards@freebsd.org Subject: _BSD_SOURCE vs. __BSD_VISIBLE X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Mar 2004 23:07:10 -0000 < said: > On FreeBSD, _BSD_SOURCE is not recognized, but _POSIX_C_SOURCE is and > it actually causes the BSD functions to be hidden. So I have to manually > add __BSD_VISIBLE to get them on FreeBSD. Then your code is wrong. If you don't want POSIX namespace, then you shouldn't be defining _POSIX_C_SOURCE. Application code has no business defining __BSD_VISIBLE. > Q1: Why does Linux require _BSD_SOURCE but FreeBSD requires __BSD_VISIBLE? Because Linux (or more likely, glibc) made a bad decision. > Q3: What is the right and portable set of flags to use? None, unless your application is prepared to live within the limitations of the namespaces it requests. Don't ask for POSIX and then expect something else. -GAWollman From owner-freebsd-standards@FreeBSD.ORG Thu Mar 18 15:32:02 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CC16816A4CE for ; Thu, 18 Mar 2004 15:32:02 -0800 (PST) Received: from STVAVAPPL1.BHMSTV (unknown [207.203.42.3]) by mx1.FreeBSD.org (Postfix) with SMTP id 7508D43D1D for ; Thu, 18 Mar 2004 15:32:02 -0800 (PST) (envelope-from archie@dellroad.org) Received: from unknown(10.104.180.64) by STVAVAPPL1.BHMSTV via csmap id 24fe0344_7933_11d8_8538_00304811e8c8_31068; Thu, 18 Mar 2004 17:22:37 -0600 (CST) Received: from arch20m.dellroad.org (localhost [127.0.0.1]) i2INVTCm005181; Thu, 18 Mar 2004 17:31:29 -0600 (CST) (envelope-from archie@arch20m.dellroad.org) Received: (from archie@localhost) by arch20m.dellroad.org (8.12.9p2/8.12.9/Submit) id i2INVSIb005180; Thu, 18 Mar 2004 17:31:28 -0600 (CST) (envelope-from archie) From: Archie Cobbs Message-Id: <200403182331.i2INVSIb005180@arch20m.dellroad.org> In-Reply-To: <200403182307.i2IN7403029016@khavrinen.lcs.mit.edu> To: Garrett Wollman Date: Thu, 18 Mar 2004 17:31:28 -0600 (CST) X-Mailer: ELM [version 2.4ME+ PL99b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII cc: freebsd-standards@FreeBSD.ORG Subject: Re: _BSD_SOURCE vs. __BSD_VISIBLE X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Mar 2004 23:32:02 -0000 Garrett Wollman wrote: > > On FreeBSD, _BSD_SOURCE is not recognized, but _POSIX_C_SOURCE is and > > it actually causes the BSD functions to be hidden. So I have to manually > > add __BSD_VISIBLE to get them on FreeBSD. > > Then your code is wrong. If you don't want POSIX namespace, then you > shouldn't be defining _POSIX_C_SOURCE. So you're saying that _POSIX_C_SOURCE is not an additive thing, it's a restrictive thing. This is different semantics from other flags (which serve to include symbols rather than omit them), which is contributing to my confusion. E.g. _GNU_SOURCE on Linux. Are these flags documented somewhere? > > Q1: Why does Linux require _BSD_SOURCE but FreeBSD requires __BSD_VISIBLE? > > Because Linux (or more likely, glibc) made a bad decision. Can you elaborate? > > Q3: What is the right and portable set of flags to use? > > None, unless your application is prepared to live within the > limitations of the namespaces it requests. Don't ask for POSIX and > then expect something else. I want everything.. on Linux I need at least _GNU_SOURCE to get it, otherwise my compilation fails due to undeclared stuff. Why did Linux choose to arrange things so that the "default" is to not show everything? Don't just say they made a "bad decision".. they must have had some rationale, even if flawed. -Archie __________________________________________________________________________ Archie Cobbs * CTO, Awarix * http://www.awarix.com From owner-freebsd-standards@FreeBSD.ORG Thu Mar 18 15:55:43 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E73216A4CE for ; Thu, 18 Mar 2004 15:55:43 -0800 (PST) Received: from mailout2.pacific.net.au (mailout2.pacific.net.au [61.8.0.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4EA2443D2D for ; Thu, 18 Mar 2004 15:55:42 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87])i2INtcnX016651; Fri, 19 Mar 2004 10:55:38 +1100 Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) i2INtaGi014860; Fri, 19 Mar 2004 10:55:37 +1100 Date: Fri, 19 Mar 2004 10:55:35 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Archie Cobbs In-Reply-To: <200403182233.i2IMXPuJ002724@arch20m.dellroad.org> Message-ID: <20040319102323.Q23424@gamplex.bde.org> References: <200403182233.i2IMXPuJ002724@arch20m.dellroad.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-standards@freebsd.org Subject: Re: _BSD_SOURCE vs. __BSD_VISIBLE X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Mar 2004 23:55:43 -0000 On Thu, 18 Mar 2004, Archie Cobbs wrote: > All I'm trying to do is write some portable code :-) > > Here "portable" simply means that it compiles on both FreeBSD and Linux. > In order to get the various functions I need I have to set a bunch of flags. > > On Linux, these flags do the trick (taken from configure.in): > > AC_DEFINE(_XOPEN_SOURCE, 600, XOpen functions) > AC_DEFINE(_GNU_SOURCE, 1, GNU functions) > AC_DEFINE(_BSD_SOURCE, 1, BSD functions) > AC_DEFINE(_ISOC99_SOURCE, 1, ISO C99 functions) > AC_DEFINE(_POSIX_VERSION, 200112, POSIX version) > AC_DEFINE(_POSIX_C_SOURCE, 200112, POSIX functions) Using these tends to restrict potability. Defining _POSIX_C_SOURCE restricts visibility to the specified version of POSIX, except some settings of _XOPEN_SOURCE have precedence and restrict visibility to the specified version of XSI. Defining the others gives undefined behaviour; the actual behaviour is to have no effect under FreeBSD, but apparently these identifiers are part of the Linux defacto standard so they do something there. FreeBSD has _C99_SOURCE, which may work like _ISOC99_SOURCE, and _ANSI_SOURCE which restricts to C90, and _POSIX_SOURCE which restricts to the POSIX.1-1990. > On FreeBSD, _BSD_SOURCE is not recognized, but _POSIX_C_SOURCE is and > it actually causes the BSD functions to be hidden. So I have to manually > add __BSD_VISIBLE to get them on FreeBSD. The only way to get all (Free)BSD functions under FreeBSD is to not define any identifiers that restrict visibility. > Q1: Why does Linux require _BSD_SOURCE but FreeBSD requires __BSD_VISIBLE? Linux apparently requires _BSD_SOURCE to give BSD extensions. This is a bug in Linux. The BSD extensions are better of course :-), and feature tests macros should generally restrict, not enable extensions. I think Linux does this because some BSD extensions are incompatible. FreeBSD doesn't require __BSD_VISIBLE. On the contrary, __BSD_VISIBLE is an implementation detail, and setting it in applications gives undefined behaviour. > Q2: Is there some standard for these flags documented somewhere? _POSIX_C_SOURCE and _XOPEN_SOURCE are documented in the POSIX.1-2001 standard. So is _POSIX_VERSION, but it is quite different (the system defines it). The others are nonstandard. > Q3: What is the right and portable set of flags to use? There is none. For FreeBSD, you probably need a null set of flags. For Linux, this is the wrong list to ask on :-). Bruce From owner-freebsd-standards@FreeBSD.ORG Fri Mar 19 09:51:43 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CD09516A4CE for ; Fri, 19 Mar 2004 09:51:43 -0800 (PST) Received: from hda.hda.com (host65.hda.com [63.104.68.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id EBAA743D2F for ; Fri, 19 Mar 2004 09:51:41 -0800 (PST) (envelope-from dufault@hda.com) Received: from [198.252.184.80] (skinny.hda.com [198.252.184.80]) by hda.hda.com (8.11.6/8.11.6) with ESMTP id i2JHvNF94981; Fri, 19 Mar 2004 12:57:23 -0500 (EST) (envelope-from dufault@hda.com) In-Reply-To: <200403182331.i2INVSIb005180@arch20m.dellroad.org> References: <200403182331.i2INVSIb005180@arch20m.dellroad.org> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <119431E2-79CE-11D8-990F-000393B2C586@hda.com> Content-Transfer-Encoding: 7bit From: Peter Dufault Date: Fri, 19 Mar 2004 12:51:37 -0500 To: Archie Cobbs X-Mailer: Apple Mail (2.612) cc: freebsd-standards@freebsd.org Subject: Re: _BSD_SOURCE vs. __BSD_VISIBLE X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Mar 2004 17:51:43 -0000 On Mar 18, 2004, at 6:31 PM, Archie Cobbs wrote: > Garrett Wollman wrote: >>> On FreeBSD, _BSD_SOURCE is not recognized, but _POSIX_C_SOURCE is and >>> it actually causes the BSD functions to be hidden. So I have to >>> manually >>> add __BSD_VISIBLE to get them on FreeBSD. >> >> Then your code is wrong. If you don't want POSIX namespace, then you >> shouldn't be defining _POSIX_C_SOURCE. > > So you're saying that _POSIX_C_SOURCE is not an additive thing, > it's a restrictive thing. > > This is different semantics from other flags (which serve to include > symbols rather than omit them), which is contributing to my confusion. > E.g. _GNU_SOURCE on Linux. > > Are these flags documented somewhere? The POSIX ones are. Bruce can cryptically correct me, but I think basically: _POSIX_C_SOURCE specifies a set of symbols that must and that can be published, based on what you set _POSIX_C_SOURCE to. It is set to a date representing one of the approved POSIX specs. It must be defined before including . Additional symbols can not be published, unless they are enabled by another feature test macro (e.g., __BSD_VISIBLE) or unless _POSIX_C_SOURCE is set to a value representing a date newer than the specification you're reading, which means if you set it to a value, newer stuff can't show up. Got that part? So (and I'm guilty for some of this), a feature test macro such as __BSD_VISIBLE is not intended for the end user (the two underbars are supposed to imply that) but is to set things up internally based on combinations of other items such as the date setting of _POSIX_C_SOURCE, whether a given item is historically expected to show up in a given environment, or other finer-grained selections. I'll duck now, but maybe FreeBSD should set __BSD_VISIBLE if _BSD_SOURCE is defined. I'm pretty sure the POSIX spec suggests exactly this sort of setting. To be really portable, try setting _POSIX_C_SOURCE to a certain date, based on a published POSIX spec, not setting any other feature test macros on the command line or before including , and getting the application to work. If you can get your application to work, then a non-conforming system is at fault. Good luck - Peter > Peter Dufault HD Associates, Inc. From owner-freebsd-standards@FreeBSD.ORG Sat Mar 20 13:17:09 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9094916A501; Sat, 20 Mar 2004 13:17:07 -0800 (PST) Received: from smtp2.server.rpi.edu (smtp2.server.rpi.edu [128.113.2.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id D11EF43DD2; Sat, 20 Mar 2004 12:51:45 -0800 (PST) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp2.server.rpi.edu (8.12.8/8.12.8) with ESMTP id i2KKpWEw020752; Sat, 20 Mar 2004 15:51:32 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: Date: Sat, 20 Mar 2004 15:51:31 -0500 To: freebsd-standards@FreeBSD.org From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: CanIt (www . canit . ca) cc: Alexey Dokuchaev Subject: PATCH for a more-POSIX `ps', and related adventures X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Mar 2004 21:17:12 -0000 [this is BCC'ed to -arch so more people have a chance to see it, but I expect most of the discussion to happen in freebsd-standards]. It started out that I just wanted to get rid of one message that `ps' writes to stderr in -current but not in -stable. "As long as I was there", I thought I'd add support for a comma-separated list of processes for `ps -p' (as described in SUSv3). Alexey Dokuchaev asked if this change got us much closer to POSIX/SUS. Now it did get us a *little* closer, but in re-reading SUSv3 I realized that I didn't get it (that one option) quite as close as I would like. So, "as long as I was there", I figured I should try to come a little closer. Now, after about 30 consecutive "as long as I was there" small projects, I have an update which: Changes -p so it accepts a list of process IDs, and -t so it accepts a list of terminal names (instead of only allowing a single value). Adds the -A option of SUSv3 (exactly the same as `-ax') Adds the `-G gidlist' and '-g pgidlist' options of SYSv3. (note that this replaced a null `-g' option...) Adds a `-R ruserlist' option, which is the same as what SYSv3 describes for `-u' (we already have a `-u'). Amazingly, none of solaris, linux, or irix seem to have any kind of `-R' option. Adds a `-s sidlist' option, which is not in SUSv3, but it is in solaris, linux, and irix -- and it's an option I have personally wished for on occasion... Allows the user to specify any of these "selector options" multiple times, and have it keep adding to that list instead of replacing values for that list. Better parsing of options. Better error messages for invalid values (IMO). Fixes interactions between all these "selector options", & our `-x' option (which is not mentioned in SUSv3). For the selector options, I tried to meet the description of: "If any are specified, the default list shall be ignored and ps shall select the processes represented by the inclusive OR of all the selection-criteria options." Applies all these selection criteria *before* sorting the list of processes we get from kvm_getprocs(), and before using the list to compute the sizes of the output fields. That does not get us matching POSIX/SUSv3, but it does get us a lot closer. There are a few questions/issues that came up for me while writing this, but I'll list those in separate messages. I'll also do a minimal update to the man page before commiting this. I wanted to do this without bloating up the size of `ps' by too much, and on i386 the executable has grown by --- 164 bytes! (0.6% increase)! [at this point I will do a touchdown-style victory dance, and spike my keyboard into the floor...] The update weighs in at almost 900 lines, and is available at: http://people.freebsd.org/~gad/ps-susv3.diff I certainly didn't intend to end up with that large of an update, but at this point I'm not going to go back and try to break it down into 30 separate updates of 50 lines each... Please look it over, try it out, and let me know if these options seem to work the way you'd expect them to, or if I have messed anything up. And please please PLEASE -- don't give me any more ideas of something *else* I could do "as long as I'm there"! -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu From owner-freebsd-standards@FreeBSD.ORG Sat Mar 20 14:21:32 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 26D1216A4CE for ; Sat, 20 Mar 2004 14:21:32 -0800 (PST) Received: from smtp1.server.rpi.edu (smtp1.server.rpi.edu [128.113.2.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id BBC7643D39 for ; Sat, 20 Mar 2004 14:21:31 -0800 (PST) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp1.server.rpi.edu (8.12.8/8.12.8) with ESMTP id i2KMLUHB019082 for ; Sat, 20 Mar 2004 17:21:31 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: Date: Sat, 20 Mar 2004 17:21:29 -0500 To: freebsd-standards@freebsd.org From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: CanIt (www . canit . ca) Subject: Re: PATCH for a more-POSIX `ps', and related adventures X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Mar 2004 22:21:32 -0000 Apologies in advance for the length of this. I seem to be in "stream-of-consciousness" mode this week... - - - - - >That does not get us matching POSIX/SUSv3, but it does get us a >lot closer. There are a few questions/issues that came up for me >while writing this, but I'll list those in separate messages. I'll >also do a minimal update to the man page before commiting this. Wrt "standards issues", the following things came up. I made arbitrary decisions on these things, and wanted to know what other people felt. With the new '-g pgidlist' option: This is a standard option in posix, and I never remembered using a -g option, and our man page for `ps' does not mention one. Much to my surprise, there already was a -g option in the option-processing code of `ps': case 'g': break; /* no-op */ A quick check of FreeBSD, NetBSD, and OpenBSD shows that everyone has had this no-op option, going back to 1993/1994. More amusing, SUSv3 writes: "The -A option is equivalent to the BSD -g and the SVID -e. Because the two systems differed, a mnemonic compromise was selected." So, what BSD had a `-g' option which behaved like `-A'? In any case, I figured that if the option has been a no-op, and undocumented for 10+ years, that it would be safe to just steal it. I am going to assume this is okay, unless there is some strong objection to it. - - - - - The SUSv3 standard describes an option `-U userlist': Write information for processes whose real user ID numbers or login names are given in userlist We already have a `-u`, and I even use it, so I wasn't going to steal that! However, I did want to have this ability, so I added it as -R. I will assume this seems reasonable. - - - - - SUSv3 does not describe the option `-s sidlist', but many of the other ps's that I work with have it, and I like having that ability. I can imagine people screaming "creeping featurism!", but hey, I was on a roll and it seemed like a pretty safe thing (standards- wise) to add. I *like* creeping features, as long as they don't bloat the code too much... - - - - - Indirectly related to that, I noticed that there was a flag named KERN_PROC_SESSION defined for the kvm_getprocs() routine. But when I tried to use that flag, I get an error: ps: kvm_getprocs: No such file or directory I do not have the time to look into this, so I guess I should write up a PR for it. (or is it not-supposed to work?). It was easy to avoid that by having the main() routine always do the selection for '-s' processing. - - - - - One of the things I puzzled over for awhile was how `-x' processing should interact with all the "selector options". I decided that by default, all the options (except -p) should act like -x was NOT specified. By that I mean they will NOT match processes which have no controlling terminal. (it is a little confusing to discuss this, due to all the double-and-triple negatives...). That way, if the user does want to see those extra processes, they can specify -x to see them, no matter what selectors were specified. If I did it the other way, then the user would need yet another (new) option to indicate that they did NOT want to see those processes. I also reasoned that 'ps' (with no options) should behave the same as 'ps -U myuserid'. Prior to my updates, 'ps -U userid' DID show the extra processes, but a plain 'ps' did not. So, what I have implemented is a slight change in behavior. The code in question had said: case 'U': uids = getuids(optarg, &nuids); xflg++; /* XXX: intuitive? */ break; And I decided to answer that as "No". This is a minor change in behavior, but I'm hoping that in practice nobody will have any problems due to this. If they do, "just add -x"... - - - - - Obviously the code for `-p pidlist' should show every process it is told to, without caring if it has a controlling terminal. The code used to do this by: case 'p': pid = atol(optarg); xflg = 1; break; But that sets the "global xflg processing switch" for *all* selector options given on the command, and I didn't think that was right. So I removed the xflg setting from there, but changed the way the selection was done such that the pidlist is matched before checking xflag. - - - - - For `-U', there is a minor change in error-processing behavior which should probably be done to match the standards, and to match how other operating systems handle the same errors. But I did not make that change, because it was possible someone cares about the behavior. And that is: If you specify multiple userids, and if any of those userids are *invalid* (which is to say, there *is* no such username or userid), then we presently print out a warning message and ignore that one parameter. We do not abort the command. So if you do: ps -U root,gad,mail,baduser you get a full 'ps' output with the warning message way at the top of it. When I tried this on other operating systems, they all aborted the command with an error, and did not list any processes. That is what I would *like* to do with our `ps', but I could imagine someone who was used to that behavior and depended on it for some silly scripts or command-aliases that they have written. So, I left it as a warning -- but only for the `-U' option. For all other options, any value which would never be valid is treated as a fatal error. Would it be alright if I changed that to a fatal error, and thus removed the ten lines of comments where I'm wringing my hands in angst over making that change? - - - - - My original intent was to MFC all of this to 4.x-stable before 4.10-release, but if I do that I will skip anything which is a "new behavior". I think that means it would be easier to skip MFC-ing it at all (or at least wait until after 4.10-release). -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu From owner-freebsd-standards@FreeBSD.ORG Sat Mar 20 15:22:54 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5BDA116A4CE for ; Sat, 20 Mar 2004 15:22:54 -0800 (PST) Received: from smtp.des.no (flood.des.no [217.116.83.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1857043D2D for ; Sat, 20 Mar 2004 15:22:54 -0800 (PST) (envelope-from des@des.no) Received: by smtp.des.no (Pony Express, from userid 666) id 001155309; Sun, 21 Mar 2004 00:22:52 +0100 (CET) Received: from dwp.des.no (des.no [80.203.228.37]) by smtp.des.no (Pony Express) with ESMTP id 346FE5308; Sun, 21 Mar 2004 00:22:46 +0100 (CET) Received: by dwp.des.no (Postfix, from userid 2602) id 84C0E33C6C; Sun, 21 Mar 2004 00:22:45 +0100 (CET) To: Garance A Drosihn References: From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Date: Sun, 21 Mar 2004 00:22:45 +0100 In-Reply-To: (Garance A. Drosihn's message of "Sat, 20 Mar 2004 17:21:29 -0500") Message-ID: User-Agent: Gnus/5.090024 (Oort Gnus v0.24) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on flood.des.no X-Spam-Level: X-Spam-Status: No, hits=0.0 required=5.0 tests=AWL autolearn=no version=2.63 cc: freebsd-standards@freebsd.org Subject: Re: PATCH for a more-POSIX `ps', and related adventures X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Mar 2004 23:22:54 -0000 Garance A Drosihn writes: > So, what BSD had a `-g' option which behaved like `-A'? SunOS, at least. In Solaris, there is still a difference between '/usr/ucb/ps uxw' and '/usr/ucb/ps guxw'. I'm so used to it, I'll probably take your name in vain a couple of times after you commit your patch. Don't let that stop you, though :) > The SUSv3 standard describes an option `-U userlist': > Write information for processes whose real user ID numbers > or login names are given in userlist > We already have a `-u`, and I even use it, so I wasn't going to > steal that! However, I did want to have this ability, so I added > it as -R. I will assume this seems reasonable. What's the difference between the existing -U and the new -R? DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no From owner-freebsd-standards@FreeBSD.ORG Sat Mar 20 16:16:06 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 011BD16A4CE for ; Sat, 20 Mar 2004 16:16:06 -0800 (PST) Received: from smtp3.server.rpi.edu (smtp3.server.rpi.edu [128.113.2.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA6D243D31 for ; Sat, 20 Mar 2004 16:16:05 -0800 (PST) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp3.server.rpi.edu (8.12.8/8.12.8) with ESMTP id i2L0G3LP016823; Sat, 20 Mar 2004 19:16:03 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: Date: Sat, 20 Mar 2004 19:16:02 -0500 To: des@des.no (Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= ) From: Garance A Drosihn Content-Type: text/plain; charset="iso-8859-1" ; format="flowed" Content-Transfer-Encoding: quoted-printable X-Scanned-By: CanIt (www . canit . ca) cc: freebsd-standards@freebsd.org Subject: Re: PATCH for a more-POSIX `ps', and related adventures X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2004 00:16:06 -0000 At 12:22 AM +0100 3/21/04, Dag-Erling Sm=F8rgrav wrote: > >> The SUSv3 standard describes an option `-U userlist': >> Write information for processes whose real user ID numbers >> or login names are given in userlist >> We already have a `-u`, and I even use it, so I wasn't going to >> steal that! However, I did want to have this ability, so I added >> it as -R. I will assume this seems reasonable. > >What's the difference between the existing -U and the new -R? "real user" vs "user". Basically, whether or not you will see setuid programs that the user has started up. For instance, right now on my system: (22) ps -x -o pid,user,uid,ruid,tt,command -U scatters PID USER UID RUID TT COMMAND 919 scatters 561 561 p1 /usr/local/bin/bash 1098 scatters 561 561 p2 /usr/local/bin/bash (23) ps -x -o pid,user,uid,ruid,tt,command -R scatters PID USER UID RUID TT COMMAND 917 root 0 561 ?? screen 1096 root 0 561 ?? screen 919 scatters 561 561 p1 /usr/local/bin/bash 1098 scatters 561 561 p2 /usr/local/bin/bash -- Garance Alistair Drosehn =3D gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu From owner-freebsd-standards@FreeBSD.ORG Sat Mar 20 16:39:13 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D043B16A4D1 for ; Sat, 20 Mar 2004 16:39:13 -0800 (PST) Received: from smtp3.server.rpi.edu (smtp3.server.rpi.edu [128.113.2.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id 730CB43D1D for ; Sat, 20 Mar 2004 16:39:13 -0800 (PST) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp3.server.rpi.edu (8.12.8/8.12.8) with ESMTP id i2L0d9LP020344; Sat, 20 Mar 2004 19:39:11 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: Date: Sat, 20 Mar 2004 19:39:08 -0500 To: des@des.no (Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= ) From: Garance A Drosihn Content-Type: text/plain; charset="iso-8859-1" ; format="flowed" Content-Transfer-Encoding: quoted-printable X-Scanned-By: CanIt (www . canit . ca) cc: freebsd-standards@freebsd.org Subject: Re: PATCH for a more-POSIX `ps', and related adventures X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2004 00:39:13 -0000 At 12:22 AM +0100 3/21/04, Dag-Erling Sm=F8rgrav wrote: >Garance A Drosihn writes: >> So, what BSD had a `-g' option which behaved like `-A'? > >SunOS, at least. In Solaris, there is still a difference between >'/usr/ucb/ps uxw' and '/usr/ucb/ps guxw'. Ah. I have solaris here, but never think to run /usr/ucb/ps. Interesting. So, the writeup in SUSv3 is at least somewhat confusing, if not wrong. When describing -A vs -a, it says: -a Write information for all processes associated with terminals. Implementations may omit session leaders from this list. -A Write information for all processes. And later it says: The -A option is equivalent to the BSD -g and the SVID -e. but that "BSD -g" does not *select* all processes, it just adds the appropriate session-leader processes to whatever you have selected via other options. So, that `-g' operates like `-x'. And the implementation of `-A' on solaris and linux indicates that they read the above the same way I did, which is to say that `-A' causes *every* process on the system to be displayed. And this does seem to be the same as "SVID -e". I'm not sure what to think about that, but it's interesting to make a note of it. -- Garance Alistair Drosehn =3D gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu From owner-freebsd-standards@FreeBSD.ORG Sat Mar 20 19:50:48 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0AB0D16A4CE for ; Sat, 20 Mar 2004 19:50:48 -0800 (PST) Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [128.30.28.20]) by mx1.FreeBSD.org (Postfix) with ESMTP id B5FEF43D31 for ; Sat, 20 Mar 2004 19:50:47 -0800 (PST) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: from khavrinen.lcs.mit.edu (localhost [IPv6:::1]) by khavrinen.lcs.mit.edu (8.12.9/8.12.9) with ESMTP id i2L3ohtx044843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK CN=khavrinen.lcs.mit.edu issuer=SSL+20Client+20CA); Sat, 20 Mar 2004 22:50:43 -0500 (EST) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.12.9/8.12.9/Submit) id i2L3ohKf044840; Sat, 20 Mar 2004 22:50:43 -0500 (EST) (envelope-from wollman) Date: Sat, 20 Mar 2004 22:50:43 -0500 (EST) From: Garrett Wollman Message-Id: <200403210350.i2L3ohKf044840@khavrinen.lcs.mit.edu> To: Archie Cobbs In-Reply-To: <200403182331.i2INVSIb005180@arch20m.dellroad.org> References: <200403182307.i2IN7403029016@khavrinen.lcs.mit.edu> <200403182331.i2INVSIb005180@arch20m.dellroad.org> X-Spam-Score: -19.8 () IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES X-Scanned-By: MIMEDefang 2.37 cc: freebsd-standards@FreeBSD.ORG Subject: Re: _BSD_SOURCE vs. __BSD_VISIBLE X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2004 03:50:48 -0000 < said: > I want everything.. on Linux I need at least _GNU_SOURCE to get it, > otherwise my compilation fails due to undeclared stuff. Why did Linux > choose to arrange things so that the "default" is to not show everything? > Don't just say they made a "bad decision".. they must have had some > rationale, even if flawed. Perhaps you should ask a Linux developer that question. I can hardly speak for them. By my reading of the standard, if the application defines _POSIX_C_SOURCE to a recognized value, then any system header files included *must not* declare any symbols outside the namespaces reserved in the Standard for those header files. (If the application defines _POSIX_C_SOURCE and then includes a non-Standard system header file, all bets are off, and in many cases compilation will and ought to break.) If an application defines a macro in the implementation name space, then the compiler is free to compile the module as an implementation of `system("rogue");'. -GAWollman