mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Use strerror in uClibc, which doesn't have sys_errlist
https://github.com/fish-shell/fish-shell/pull/808
This commit is contained in:
parent
2eb97edf02
commit
cfe815135e
1 changed files with 6 additions and 0 deletions
|
@ -319,6 +319,11 @@ static inline void safe_append(char *buffer, const char *s, size_t buffsize)
|
||||||
|
|
||||||
const char *safe_strerror(int err)
|
const char *safe_strerror(int err)
|
||||||
{
|
{
|
||||||
|
#if defined(__UCLIBC__)
|
||||||
|
// uClibc does not have sys_errlist, however, its strerror is believed to be async-safe
|
||||||
|
// See #808
|
||||||
|
return strerror(err);
|
||||||
|
#else
|
||||||
if (err >= 0 && err < sys_nerr && sys_errlist[err] != NULL)
|
if (err >= 0 && err < sys_nerr && sys_errlist[err] != NULL)
|
||||||
{
|
{
|
||||||
return sys_errlist[err];
|
return sys_errlist[err];
|
||||||
|
@ -340,6 +345,7 @@ const char *safe_strerror(int err)
|
||||||
errno = saved_err;
|
errno = saved_err;
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void safe_perror(const char *message)
|
void safe_perror(const char *message)
|
||||||
|
|
Loading…
Reference in a new issue