summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/misc.c b/misc.c
index 84c94f9b6..c457a952c 100644
--- a/misc.c
+++ b/misc.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: misc.c,v 1.20 2002/12/13 10:03:15 markus Exp $"); 26RCSID("$OpenBSD: misc.c,v 1.21 2003/04/12 10:15:36 markus Exp $");
27 27
28#include "misc.h" 28#include "misc.h"
29#include "log.h" 29#include "log.h"
@@ -60,7 +60,7 @@ set_nonblock(int fd)
60 debug2("fd %d is O_NONBLOCK", fd); 60 debug2("fd %d is O_NONBLOCK", fd);
61 return; 61 return;
62 } 62 }
63 debug("fd %d setting O_NONBLOCK", fd); 63 debug2("fd %d setting O_NONBLOCK", fd);
64 val |= O_NONBLOCK; 64 val |= O_NONBLOCK;
65 if (fcntl(fd, F_SETFL, val) == -1) 65 if (fcntl(fd, F_SETFL, val) == -1)
66 debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s", 66 debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
@@ -308,47 +308,18 @@ addargs(arglist *args, char *fmt, ...)
308{ 308{
309 va_list ap; 309 va_list ap;
310 char buf[1024]; 310 char buf[1024];
311 int nalloc;
312 311
313 va_start(ap, fmt); 312 va_start(ap, fmt);
314 vsnprintf(buf, sizeof(buf), fmt, ap); 313 vsnprintf(buf, sizeof(buf), fmt, ap);
315 va_end(ap); 314 va_end(ap);
316 315
317 nalloc = args->nalloc;
318 if (args->list == NULL) { 316 if (args->list == NULL) {
319 nalloc = 32; 317 args->nalloc = 32;
320 args->num = 0; 318 args->num = 0;
321 } else if (args->num+2 >= nalloc) 319 } else if (args->num+2 >= args->nalloc)
322 nalloc *= 2; 320 args->nalloc *= 2;
323 321
324 args->list = xrealloc(args->list, nalloc * sizeof(char *)); 322 args->list = xrealloc(args->list, args->nalloc * sizeof(char *));
325 args->nalloc = nalloc;
326 args->list[args->num++] = xstrdup(buf); 323 args->list[args->num++] = xstrdup(buf);
327 args->list[args->num] = NULL; 324 args->list[args->num] = NULL;
328} 325}
329
330mysig_t
331mysignal(int sig, mysig_t act)
332{
333#ifdef HAVE_SIGACTION
334 struct sigaction sa, osa;
335
336 if (sigaction(sig, NULL, &osa) == -1)
337 return (mysig_t) -1;
338 if (osa.sa_handler != act) {
339 memset(&sa, 0, sizeof(sa));
340 sigemptyset(&sa.sa_mask);
341 sa.sa_flags = 0;
342#if defined(SA_INTERRUPT)
343 if (sig == SIGALRM)
344 sa.sa_flags |= SA_INTERRUPT;
345#endif
346 sa.sa_handler = act;
347 if (sigaction(sig, &sa, NULL) == -1)
348 return (mysig_t) -1;
349 }
350 return (osa.sa_handler);
351#else
352 return (signal(sig, act));
353#endif
354}