1 /* ----------------------------------------------------------------------- *
3 * Copyright 2001-2007 H. Peter Anvin - All Rights Reserved
5 * This program is free software available under the same license
6 * as the "OpenBSD" operating system, distributed at
7 * http://www.openbsd.org/.
9 * ----------------------------------------------------------------------- */
14 * Minor help routines.
17 #include "config.h" /* Must be included first! */
22 * Set the signal handler and flags. Basically a user-friendly
23 * wrapper around sigaction().
25 void set_signal(int signum
, void (*handler
) (int), int flags
)
29 memset(&sa
, 0, sizeof sa
);
30 sa
.sa_handler
= handler
;
31 sigemptyset(&sa
.sa_mask
);
34 if (sigaction(signum
, &sa
, NULL
)) {
35 syslog(LOG_ERR
, "sigaction: %m");
41 * malloc() that syslogs an error message and bails if it fails.
43 void *tfmalloc(size_t size
)
45 void *p
= malloc(size
);
48 syslog(LOG_ERR
, "malloc: %m");
56 * strdup() that does the equivalent
58 char *tfstrdup(const char *str
)
60 char *p
= strdup(str
);
63 syslog(LOG_ERR
, "strdup: %m");