2 /* ----------------------------------------------------------------------- *
4 * Copyright 2001 H. Peter Anvin - All Rights Reserved
6 * This program is free software available under the same license
7 * as the "OpenBSD" operating system, distributed at
8 * http://www.openbsd.org/.
10 * ----------------------------------------------------------------------- */
15 * Minor help routines.
18 #include "config.h" /* Must be included first! */
23 * Set the signal handler and flags. Basically a user-friendly
24 * wrapper around sigaction().
26 void set_signal(int signum
, void (*handler
)(int), int flags
)
30 memset(&sa
, 0, sizeof sa
);
31 sa
.sa_handler
= handler
;
32 sigemptyset(&sa
.sa_mask
);
35 if ( sigaction(signum
, &sa
, NULL
) ) {
36 syslog(LOG_ERR
, "sigaction: %m");
42 * malloc() that syslogs an error message and bails if it fails.
44 void *tfmalloc(size_t size
)
46 void *p
= malloc(size
);
49 syslog(LOG_ERR
, "malloc: %m");
57 * strdup() that does the equivalent
59 char *tfstrdup(const char *str
)
61 char *p
= strdup(str
);
64 syslog(LOG_ERR
, "strdup: %m");