:: Re: [DNG] help with C - error: impl…
Página Principal
Delete this message
Reply to this message
Autor: tito
Data:  
Para: dng
Assunto: Re: [DNG] help with C - error: implicit declaration of function
On Mon, 29 Jul 2024 14:29:25 +0200
Lorenz via Dng <dng@???> wrote:

> Hello,
> I'm an amateur and self-taught "programmer" and I need help from
> someone that knows better than me in C.
>
> Runit currently fails to build from source with gcc-14, with
> sig_pause.c:14:3: error: implicit declaration of function ‘sigpause’
> see
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1075484
>
> looked at the error, did a quick search about 'sigpause'
>
> https://man7.org/linux/man-pages/man3/sigpause.3.html
> https://www.ibm.com/docs/fi/zos/2.4.0?topic=functions-sigpause-unblock-signal-wait-signal
>
> and come up with the following patch
>
> --- a/runit-2.1.2/src/sig_pause.c
> +++ b/runit-2.1.2/src/sig_pause.c
> @@ -11,6 +11,7 @@
>    sigemptyset(&ss);
>    sigsuspend(&ss);
>  #else
> +  int sigpause(int);
>    sigpause(0);
>  #endif
>  }

>
> tested, it builds and seems to work fine, so everything ok.
> Actually, no.
> I tested the same patch in socklog; socklog is syslog daemon
> from the same upstream as runit, has many headers in common
> with runit and it fails to build with the same error
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1075523
>
> With my patch, it builds but produced binaries are unresponsive
> to SIGTERM, which of course is not ok.
>
> So, is my patch wrong? Is it wrong that the implicit type for a
> function is int?
> I don't understand, if int is the implicit type returned by the function,
> how can my patch, that only makes it explicit, change (break) the behaviour
> of socklog like that?
>
> Looking to learn something,
> Lorenzo
>
> for reference, to browse the source
> (runit)
> https://salsa.debian.org/debian/runit/-/tree/master/runit-2.1.2/src?ref_type=heads
> (socklog)
> https://salsa.debian.org/debian/socklog/-/tree/master/src?ref_type=heads
> _______________________________________________
> Dng mailing list
> Dng@???
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Hi,
maybe this helps, untested.

Ciao,
Tito

https://bugs.gentoo.org/870949
--- a/sig_pause.c
+++ b/sig_pause.c
@@ -1,5 +1,9 @@
/* Public domain. */

+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 500
+#endif
+
#include <signal.h>
#include "sig.h"
#include "hassgprm.h"


From man sigpause:

   Linux notes
       On Linux, this routine is a system call only on the Sparc (sparc64) architecture.


       glibc  uses the BSD version if the _BSD_SOURCE feature test macro is defined and none of _POSIX_SOURCE, _POSIX_C_SOURCE, _XOPEN_SOURCE, _GNU_SOURCE, or _SVID_SOURCE is defined.  Otherwise, the System V version is used, and
       feature test macros must be defined as follows to obtain the declaration:


       •  Since glibc 2.26: _XOPEN_SOURCE >= 500


       •  glibc 2.25 and earlier: _XOPEN_SOURCE


       Since glibc 2.19, only the System V version is exposed by <signal.h>; applications that formerly used the BSD sigpause() should be amended to use sigsuspend(2).