[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Incorrect return value for sigwait()
From: |
Searty, Salwan |
Subject: |
Incorrect return value for sigwait() |
Date: |
Wed, 26 Feb 2003 15:10:38 -0800 |
The behavior of the sigwait() function appears to have deviated from
complying to the POSIX spec. On a system with glibc version 2.2.5-34 (the
glibc that comes with RedHat 7.3), sigwait() returns a signal number in the
location referenced by the function's sig parameter. Sigwait() also has a
return value of zero upon success, just as defined in the POSIX system
interfaces document.
On a system with glibc version 2.2.93-5 (the one that comes with RedHat
8.0), sigwait() returns successfully, but instead of returning a 0, it
returns the signal number of the received signal. Also, it does not return
the signal number in the location referenced by sigwait()'s sig parameter.
I also tried this on a system with a more recent version of glibc checked
out from sources.redhat.com:/cvs/glibc (on 02/12/2003 if I remember
correctly), installed on a 2.5.59 kernel, and the behavior of the sigwait()
was still non-compliant with the POSIX Spec.
I don't think this is a kernel problem because sigwait() behaves correctly
with the 2.5.62bk3 kernel as long as the RedHat 7.3 version of glibc
2.2.5-34 is installed.
The test program I used to test sigwait()'s return value is appended below.
I just do a "gcc -o sig sig.c" to compile it. Note that when you compile it
with -lpthread parameter, it behaves correctly regardless of the glibc
version you're running.
Thanks,
Salwan.
**These views are not necessarily those of my employer.**
---------------------------------------------------------
#include <signal.h>
#include <stdio.h>
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that the sigwait(). If no signal in 'set' is pending at the
* time of the call, the thread shall be suspended until one or more
becomes
* pending.
* 1) Block a signal from delivery.
* 2) Raise the signal.
* 3) Call sigwait().
* 4) Verify this process will return when the signal is sent.
*/
#define SIGTOTEST SIGALRM
int main()
{
sigset_t newmask;
int sig = 0;
int ret;
/* Empty set of blocked signals */
if ( (sigemptyset(&newmask) == -1) )
{
printf("Error in sigemptyset()\n");
return -1;
}
/* Add SIGTOTEST to the set of blocked signals */
if (sigaddset(&newmask, SIGTOTEST) == -1)
{
perror("Error in sigaddset()\n");
return -1;
}
/* Block SIGTOTEST */
if (sigprocmask(SIG_SETMASK, &newmask, NULL) == -1)
{
printf("Error in sigprocmask()\n");
return -1;
}
/* Send SIGTOTEST signal to this process. Since it is blocked,
* it should be pending */
if (raise(SIGTOTEST) != 0) {
printf("Could not raise SIGTOTEST\n");
return -1;
}
/* Call sigwait and test if it passed/failed*/
ret = sigwait(&newmask, &sig);
if (ret != 0)
{
perror("sigwait() had incorrect return value");
printf("Return value from sigwait() is %d\n", ret);
printf("Signal returned in sig parameter %d, should be
%d\n",
sig, SIGTOTEST);
return -1;
}
/* If we get here, then the process was suspended until
* SIGTOTEST was raised. */
printf("Test PASSED\n");
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Incorrect return value for sigwait(),
Searty, Salwan <=