www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/02/19/07:22:09

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 51JCM94Z3934461
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 51JCM94Z3934461
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=ozXrcLhg
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32E69385840F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1739967728;
bh=9ZMKex7pAoxUI6GqrxvrCjNNTtBpaqdtKHwLsYajWbE=;
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=ozXrcLhgvpO+ctsssfCu7vGcua5VyojgQF4tR6if9O1kq4EkslXJhEWdmfsxJKDTK
TTtT1el1/sMKWp2LTvNSSwDgaD3JUvZjRVQ7A2LGGtN09xAo3HgMtl+v+B2lVJexZA
jbavucuZKuXz5TQxkud8xvsRqXi/KiTx1YmBknX8=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BAA383858C78
Date: Wed, 19 Feb 2025 13:21:05 +0100
To: cygwin AT cygwin DOT com
Subject: Re: cygwin 3.6.0 vs. libbsd 0.11.7-3: -lbsd breaks setproctitle()
Message-ID: <Z7XMsdPjKyaOrNIQ@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4250e737-217a-2b55-c6df-8567b283da15 AT t-online DOT de>
MIME-Version: 1.0
In-Reply-To: <4250e737-217a-2b55-c6df-8567b283da15@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 51JCM94Z3934461

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.

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?

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