ldattach: simplify debugging function when vwarnx(3) is available

The vwarnx(3) is probably not available in all libc implementations, in such
cases use the earlier printout as a fallback.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2017-06-24 17:01:22 +01:00
parent 8e58889065
commit 31f85fce55
No known key found for this signature in database
GPG Key ID: A9553245FDE9B739
2 changed files with 8 additions and 3 deletions

View File

@ -428,6 +428,7 @@ AC_CHECK_FUNCS([ \
sysinfo \
timegm \
usleep \
vwarnx \
warn \
warnx \
])

View File

@ -137,11 +137,15 @@ static void dbg(char *fmt, ...)
if (debug == 0)
return;
fflush(NULL);
fprintf(stderr, "%s: ", program_invocation_short_name);
va_start(args, fmt);
#ifdef HAVE_VWARNX
vwarnx(fmt, args);
#else
fprintf(stderr, "%s: ", program_invocation_short_name);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
#endif
va_end(args);
fflush(NULL);
return;
}
@ -252,7 +256,7 @@ static int my_cfsetspeed(struct termios *ts, int speed)
static void handler(int s)
{
dbg("got SIG %i -> exiting\n", s);
dbg("got SIG %i -> exiting", s);
exit(EXIT_SUCCESS);
}