Подробности
[В начало]
Проблема в реализации № S0684
Краткое описание
Неправильный вывод из psignal(int sig, const char * s) при пустой строке s
Подробное описание
В документации сказано, что при пустой строке s функция psignal должна вывести только сообщение, описывающее сигнал 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.Но на самом деле psignal выводит двоеточие, пробел, и только потом сообщение, описывающее сигнал sig.
Раздел стандарта
Linux Standard Base Core Specification 3.1, Chapter 13. Base Libraries, 13.5. Interface Definitions for libc, psignal() function.
Пример
#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;
}
Способы устранения
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
Компонент
glibc
Принято
Red Hat Bugzilla, 9823
Статус
Исправлено в glibc-2.10
[В начало]
»