Details
[Home]
Issue of the Implementation # S0684
Brief
Error in psignal(int sig, const char * s) if s is an empty string
Detailed Description
If string s is empty, psignal shall display only a message describing the signal number sig.
SYNOPSIS void psignal(int sig, const char * s); DESCRIPTION If s is not the null pointer, and does not point to an empty string (e.g. "\0"), the message shall consist of the string s, a colon, a space, and a string describing the signal number sig; otherwise psignal() shall display only a message describing the signal number sig.But actually psignal prints a colon, a space, and a string describing the signal number sig.
Problem location(s) in the standard
Linux Standard Base Core Specification 3.1, Chapter 13. Base Libraries, 13.5. Interface Definitions for libc, psignal() function.
Example
#include <stdio.h> #include <signal.h> int main( int argc, char ** argv ) { printf( "If string s is empty, psignal( sig, s ) shall display only a message describing the signal number sig.\n" ); printf( "Call psignal( 1, \"\" ) now...\n" ); psignal( 1, "" ); return 0; }
Possible solutions
diff -r1.15 psignal.c /* Print out on stderr a line consisting of the test in S, a colon, a space, a message describing the meaning of the signal number SIG and a newline. If S is NULL or "", the colon and space are omitted. */ void psignal (int sig, const char *s) { const char *colon, *desc; - if (s == NULL || s == '\0') + if (s == NULL || *s == '\0') s = colon = ""; else colon = ": "; if (sig >= 0 && sig < NSIG && (desc = INTUSE(_sys_siglist)[sig]) != NULL) (void) __fxprintf (NULL, "%s%s%s\n", s, colon, _(desc)); else
Component
glibc
Accepted
Red Hat Bugzilla, 9823
Status
Fixed in glibc-2.10
[Home]
»