NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/57215: sigprocmask return value wrong when libpthread is in use



>Number:         57215
>Category:       lib
>Synopsis:       The return value of sigprocmask is not standards compliant
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 04 02:50:00 +0000 2023
>Originator:     bruno%clisp.org@localhost
>Release:        NetBSD 9.0
>Organization:
GNU
>Environment:
System: NetBSD netbsd9.bruno.haible.de 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
When a program that is linked with libpthread uses the sigprocmask function,
its return value can be wrong.
See https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html
section "RETURN VALUE".
>How-To-Repeat:
Compile this program
==================== foo.c ================
#include <errno.h>
#include <signal.h>
#include <stdio.h>

int main ()
{
  sigset_t set;
  int ret;

  sigemptyset (&set);
  sigaddset (&set, SIGINT);

  ret = sigprocmask (1729, &set, NULL);
  if (ret == 0)
    printf ("sigprocmask succeeded!\n");
  else
    printf ("sigprocmask -> %d, errno=%d\n", ret, errno);

  ret = pthread_sigmask (1729, &set, NULL);
  if (ret == 0)
    printf ("pthread_sigmask succeeded!\n");
  else
    printf ("pthread_sigmask -> %d\n", ret);

  return 0;
}
=============================================
$ gcc -Wall foo.c -lpthread
$ ./a.out

Expected output:
sigprocmask -> -1, errno=22
pthread_sigmask -> 22

Actual output:
sigprocmask -> 22, errno=22
pthread_sigmask -> 22

>Fix:



Home | Main Index | Thread Index | Old Index