File: error.c

package info (click to toggle)
multitail 5.2.9-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 824 kB
  • sloc: ansic: 14,404; makefile: 96; sh: 51; perl: 25
file content (46 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#define _LARGEFILE64_SOURCE     /* required for GLIBC to enable stat64 and friends */
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <regex.h>
#if defined(__GLIBC__)
#include <execinfo.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>

#include "mt.h"
#include "utils.h"
#include "version.h"

void error_exit(char *file, const char *function, int line, char *format, ...)
{
	va_list ap;

	(void)endwin();

	fprintf(stderr, version_str, VERSION);
	fprintf(stderr, "\n\n");

	fprintf(stderr,"A problem occured at line %d in function %s (from file %s):\n\n", line, function, file);
	va_start(ap, format);
	(void)vfprintf(stderr, format, ap);
	va_end(ap);
	if (errno) fprintf(stderr, "\nerrno variable (if applicable): %d which means %s\n\n", errno, strerror(errno));

	fprintf(stderr, "\nBinary build at %s %s\n", __DATE__, __TIME__);

	dump_mem(SIGHUP);

	fflush(NULL);

	(void)kill(0, SIGTERM); /* terminate every process in the process group of the current process */

	exit(EXIT_FAILURE);
}