misc.c (120161) | misc.c (124208) |
---|---|
1/* 2 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 9 unchanged lines hidden (view full) --- 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25#include "includes.h" | 1/* 2 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 9 unchanged lines hidden (view full) --- 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 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.22 2003/09/18 08:49:45 markus Exp $"); |
27 28#include "misc.h" 29#include "log.h" 30#include "xmalloc.h" 31 32/* remove newline at end of string */ 33char * 34chop(char *s) --- 20 unchanged lines hidden (view full) --- 55 if (val < 0) { 56 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno)); 57 return; 58 } 59 if (val & O_NONBLOCK) { 60 debug2("fd %d is O_NONBLOCK", fd); 61 return; 62 } | 27 28#include "misc.h" 29#include "log.h" 30#include "xmalloc.h" 31 32/* remove newline at end of string */ 33char * 34chop(char *s) --- 20 unchanged lines hidden (view full) --- 55 if (val < 0) { 56 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno)); 57 return; 58 } 59 if (val & O_NONBLOCK) { 60 debug2("fd %d is O_NONBLOCK", fd); 61 return; 62 } |
63 debug("fd %d setting O_NONBLOCK", fd); | 63 debug2("fd %d setting O_NONBLOCK", fd); |
64 val |= O_NONBLOCK; 65 if (fcntl(fd, F_SETFL, val) == -1) 66 debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s", 67 fd, strerror(errno)); 68} 69 70void 71unset_nonblock(int fd) --- 249 unchanged lines hidden (view full) --- 321 } else if (args->num+2 >= nalloc) 322 nalloc *= 2; 323 324 args->list = xrealloc(args->list, nalloc * sizeof(char *)); 325 args->nalloc = nalloc; 326 args->list[args->num++] = xstrdup(buf); 327 args->list[args->num] = NULL; 328} | 64 val |= O_NONBLOCK; 65 if (fcntl(fd, F_SETFL, val) == -1) 66 debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s", 67 fd, strerror(errno)); 68} 69 70void 71unset_nonblock(int fd) --- 249 unchanged lines hidden (view full) --- 321 } else if (args->num+2 >= nalloc) 322 nalloc *= 2; 323 324 args->list = xrealloc(args->list, nalloc * sizeof(char *)); 325 args->nalloc = nalloc; 326 args->list[args->num++] = xstrdup(buf); 327 args->list[args->num] = NULL; 328} |
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} | |