gspawn: Don’t use g_ascii_isdigit() in async-signal-safe context

While `g_ascii_isdigit()` *is* currently async-signal-safe, it’s going
to be hard to remember to keep it that way if the implementation changes
in future.

It seems more robust to just reimplement it here, given that it’s not
much code.

See `man 7 signal-safety`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2140
This commit is contained in:
Philip Withnall 2020-06-22 13:10:35 +01:00
parent 6f46294227
commit 33948929df

View File

@ -1185,8 +1185,7 @@ filename_to_fd (const char *p)
while ((c = *p++) != '\0') while ((c = *p++) != '\0')
{ {
/* FIXME: g_ascii_isdigit() is not necessarily async-signal-safe. */ if (c < '0' || c > '9')
if (!g_ascii_isdigit (c))
return -1; return -1;
c -= '0'; c -= '0';