www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/02/19/08:41:34

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 51JDfYT13962038
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 51JDfYT13962038
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=jXbdxbFd
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A05FA3858405
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1739972493;
bh=IXqPGSrOhOK7R+eB4v2uZVyQepP736GtuMpTn/z1/tc=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=jXbdxbFdP34s+ZOs4zk2271xlQ3gOONuHCaCqZmWoxl7uj7d4pFIetsHBo+nd65M1
fW3yVZ5vle40VW7E1SuJXXkKTYvfV/A8TlDukxEEbqZI9aTRSTAh8KES9YsEMld9N1
ckJ+Wy+9qHrP/uD51n1oZmuqYN/6xNT7zPWmCayQ=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52B833858C5F
Date: Wed, 19 Feb 2025 14:40:32 +0100
To: cygwin AT cygwin DOT com
Subject: Re: cygwin 3.6.0 vs. libbsd 0.11.7-3: -lbsd breaks setproctitle()
Message-ID: <Z7XfUHzBmGikTBqf@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4250e737-217a-2b55-c6df-8567b283da15 AT t-online DOT de>
<Z7XMsdPjKyaOrNIQ AT calimero DOT vinschen DOT de>
<e364ba68-bafd-c79e-abbf-d1382e6d3463 AT t-online DOT de>
MIME-Version: 1.0
In-Reply-To: <e364ba68-bafd-c79e-abbf-d1382e6d3463@t-online.de>
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 51JDfYT13962038

On Feb 19 14:25, Christian Franke via Cygwin wrote:
> Hi Corinna,
> 
> Corinna Vinschen via Cygwin wrote:
> > Hi Christian,
> > 
> > On Feb 19 11:14, Christian Franke via Cygwin wrote:
> > > Testcase:
> > > 
> > > $ uname -r
> > > 3.6.0-0.375.ged18acfe8c76.x86_64
> > > 
> > > $ cygcheck -f /usr/include/bsd/unistd.h
> > > libbsd-devel-0.11.7-3
> > > 
> > > $ cat spt.c
> > > #include <unistd.h>
> > > 
> > > int main(int argc, char **argv, char **envp)
> > > {
> > >    initsetproctitle(argc, argv, envp);
> > >    setproctitle("argc = %d", argc);
> > >    sleep(2);
> > >    return 0;
> > > }
> > > 
> > > $ gcc -o spt-bsdovl -isystem /usr/include/bsd -DLIBBSD_OVERLAY spt.c -l bsd
> > > 
> > > $ gcc -o spt-bsd spt.c -l bsd
> > > 
> > > $ gcc -o spt-nobsd spt.c
> > > 
> > > $ ./spt-bsdovl
> > > spt-bsdovl: setproctitle not initialized, please either call
> > > setproctitle_init() or link against libbsd-ctor.
> > > 
> > > $ ./spt-bsd
> > > spt-bsd: setproctitle not initialized, please either call
> > > setproctitle_init() or link against libbsd-ctor.
> > > 
> > > $ ./spt-nobsd & procps -o pid,args -p $!
> > > [1] 2750
> > >    PID COMMAND
> > >   2750 spt-nobsd: argc = 1
> > The problem the Cygwin patch was supposed to fix is that the libbsd
> > version of setproctitle just doesn't work correctly on Cygwin:
> > 
> > $ uname -r
> > 3.5.7-1.x86_64
> > $ ./spt-bsdovl & procps -o pid,args -p $!
> > [1] 140
> >    PID COMMAND
> >    140 spt-bsdovl:
> > 
> > The way the include file /usr/include/bsd/unistd.h is designed,
> > we could make sure the libbsd version is used, by tweaking
> > /usr/include/sys/unistd.h:
> > 
> > diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
> > index e62e38d10ccf..732356d6a14e 100644
> > --- a/newlib/libc/include/sys/unistd.h
> > +++ b/newlib/libc/include/sys/unistd.h
> > @@ -212,7 +212,7 @@ int     setpgid (pid_t __pid, pid_t __pgid);
> >   #if __SVID_VISIBLE || __XSI_VISIBLE >= 500
> >   int     setpgrp (void);
> >   #endif
> > -#if defined(__CYGWIN__) && __BSD_VISIBLE
> > +#if defined(__CYGWIN__) && __BSD_VISIBLE && !defined(LIBBSD_OVERLAY)
> >   /* Stub for Linux libbsd compatibility. */
> >   #define initsetproctitle(c, a, e) setproctitle_init((c), (a), (e))
> >   static inline void setproctitle_init (int, char *[], char *[]) {}
> > 
> > But that still allows to link against a non-working setproctitle.
> 
> Yes, and it won't work if bsd/unistd.h is included without LIBBSD_OVERLAY
> which is discouraged but still documented on libbsd(7).
> 
> 
> > So I think we rather shouldn't supply the libbsd version of
> > setproctitle_init/setproctitle anymore, as soon as cygwin 3.6.0 is
> > released.
> > 
> > What do you think?
> 
> Makes sense. But then existing programs already using the functions from
> cygbsd-0.dll would no longer start. Perhaps keep the symbols in the DLL only
> for some time?

Sure!  The new version will just disable the header definitions but
still export the symbols for backward compat.


Thanks,
Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019