From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 8FF45267B9 for ; Fri, 8 Mar 2024 01:52:47 +0100 (CET) Received: (qmail 1178 invoked by uid 550); 8 Mar 2024 00:48:46 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 1158 invoked from network); 8 Mar 2024 00:48:46 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709859153; bh=1d9MV6MooJiQI/ULdviu5I8wI4cyhMGNWHtw1Pv8quU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GQz7RxRZi59wp/16SMnsPY5/0HHbINgm6yXbRqSf77GQr31esJI+jDeGuaZDze5Pn squK2EyBQlb8VMSO+/mzFmWloxNa6A5G9iUqf/mozIrDbT/eMsQrpPpYGY0QVoQFSr JVoKxEaUTHgCdcTgLraj+IWq1gUZzwWC5VYS6Xssese+sEUqN5XY47TYzaoi45mmGf IW4VI9aWThQ2XY/g2KUgdp4Vwe+TtE3gGXOztlgdmfJ0+nTc4v+h1CFAsMp/uTJeyk /bovFZyKpOveIJQ82dEtnmY+gCfNOs6iwphP60xpJzqorT+ANYgSLlj51nbC6mBvXd 7xYUSIC4Lt9/A== Date: Fri, 8 Mar 2024 01:52:28 +0100 From: Alejandro Colomar To: Guillem Jover , libc-alpha@sourceware.org, musl@lists.openwall.com Cc: libbsd@lists.freedesktop.org, "Serge E. Hallyn" , "Skyler Ferrante (RIT Student)" , Iker Pedrosa , Christian Brauner , shadow <~hallyn/shadow@lists.sr.ht> Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="LWonGZQzeixhxI+/" Content-Disposition: inline In-Reply-To: Subject: [musl] Re: Tweaking the program name for functions --LWonGZQzeixhxI+/ Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Fri, 8 Mar 2024 01:52:28 +0100 From: Alejandro Colomar To: Guillem Jover , libc-alpha@sourceware.org, musl@lists.openwall.com Cc: libbsd@lists.freedesktop.org, "Serge E. Hallyn" , "Skyler Ferrante (RIT Student)" , Iker Pedrosa , Christian Brauner , shadow <~hallyn/shadow@lists.sr.ht> Subject: Re: Tweaking the program name for functions [TO +=3D musl] Hi! On Fri, Mar 08, 2024 at 01:30:51AM +0100, Guillem Jover wrote: > That is not portable because the BSDs do not support that variable. > But all BSDs for which I've got a checkout (FreeBSD, NetBSD, OpenBSD, > DragonflyBSD) support changing it via setprogname(), but that's not > available in glibc (libbsd provides it though). >=20 > libbsd and cosmopolitan libc support setting it via setprogname() or > program_invocation_short_name. >=20 > musl libc supports setting it via program_invocation_short_name. >=20 > uclibc might support __progname and/or program_invocation_short_name > depending on how it has been configured, but it does not support > setting the err(3) program name via those. Hmmm. $ cat err.c=20 #define _GNU_SOURCE #include #include #include #include int main(void) { program_invocation_name =3D "foo"; program_invocation_short_name =3D "bar"; setprogname("baz"); error(0, errno, "fmt string"); err(1, "fmt2"); } $ cc -Wall -Wextra err.c -lbsd $ ./a.out=20 foo: fmt string baz: fmt2: Success This would already be portable enough for what I want, except that libbsd isn't very welcome in some OSes as a core library. I guess I'll need libc support. >=20 > > Maybe it would be interesting to get the BSDs to support these pointers? >=20 > They already have a way to control the program name though. (And > it seems to me that using functions instead of global variables is > superior. :) Indeed. I didn't know about such function. I'll reformulate my original suggestion to this other one: How about adding setprogname(3) (and getprogname(3)) to GNU and musl libc? >=20 > Thanks, > Guillem Have a lovely night! Alex --=20 Looking for a remote C programming job at the moment. --LWonGZQzeixhxI+/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmXqYUwACgkQnowa+77/ 2zKSgg//faNAY3YC7LLP+MDxNh8SgNVmmrs7DzNOtnx+rUmlTYhGxFhoKhcwDCyO M5R+zO4EBIyQqmZ6tgC3KMT7MJMl6eNZSLd1zp9APcSGy6AJIN/WG94C40m8dha4 ZXLdzUdsPxqsSe26ha/XOVRheNXpu2A3tbAtgh8Iwe8f/KlJ7s8EbjjIW0MnFf2k phyrVoMBUevGtUbvaky5l2cdBxSiTb/jT84NoQwHMIJ3NlQQQvkqczk7YjkVNNdS ZW05sEfIGkF7QgZShSz5FI1P6tQ1r8FTI9lEGjGly08qeyaRI5zkAEURtP0xcVSs 4ZGpzhC+V/F5fbViJSm0fst6ToRSjqOM992VDgPX3E0Hk3WOhi/XMwk7UwXnzfty Xtygi+nEh/Ed42uu6W8hVHT2U5GRtq+aCIO7sfp+wDVlMmpRL9paAFTBCZxNOV4J 4kPuxTqLmU06eNsQJyzm2BAs3QCCTWykit0K6gLLWwOJvt05F2hVHe50BeNzGdF7 9DVqkVf1RShDpMIK2vOcFEOjG3GSQTLSIRNiFrRZEIzT82daUkjgFnReQKS1hghj q8pwpp77f8vGBxxN51wUOOROd43f05qK/Wlo9RSKbAJKGX2EzuVUpsUt7N3j+UhH vJkrCaLV9xYiBl6SGgmCS9bKKNIDOMaT7T5XZbevLwWcxf5shFQ= =B4G3 -----END PGP SIGNATURE----- --LWonGZQzeixhxI+/--