implement error() for musl

This commit is contained in:
Daniel Barlow 2024-09-16 20:35:23 +01:00
parent 5771108fed
commit d3fce5edd4
1 changed files with 17 additions and 1 deletions

View File

@ -6,12 +6,28 @@
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <error.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#ifdef _GNU_SOURCE
#include <error.h>
#else
#include <stdarg.h>
static void error(int status, int errnum, const char * fmt, ...) {
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "logtee: ");
vfprintf(stderr, fmt, ap);
if(errnum) fprintf(stderr, ": %s", strerror(errnum));
fprintf(stderr, "\n");
if(status) exit(status);
}
#endif
int open_shipper_socket(char *pathname) {
int fd;
static int fail_count = 0;